aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/Kconfig42
-rw-r--r--arch/alpha/boot/tools/mkbb.c2
-rw-r--r--arch/alpha/kernel/console.c70
-rw-r--r--arch/alpha/kernel/core_marvel.c43
-rw-r--r--arch/alpha/kernel/core_titan.c70
-rw-r--r--arch/alpha/kernel/core_tsunami.c24
-rw-r--r--arch/alpha/kernel/entry.S7
-rw-r--r--arch/alpha/kernel/pci_iommu.c3
-rw-r--r--arch/alpha/kernel/proto.h9
-rw-r--r--arch/alpha/kernel/setup.c3
-rw-r--r--arch/alpha/kernel/signal.c110
-rw-r--r--arch/alpha/kernel/sys_dp264.c11
-rw-r--r--arch/alpha/kernel/sys_marvel.c4
-rw-r--r--arch/alpha/kernel/sys_titan.c2
-rw-r--r--arch/alpha/kernel/systbls.S32
-rw-r--r--arch/alpha/lib/Makefile3
-rw-r--r--arch/alpha/lib/fls.c38
-rw-r--r--arch/arm/kernel/armksyms.c2
-rw-r--r--arch/arm/kernel/stacktrace.c2
-rw-r--r--arch/arm/mach-at91/board-dk.c2
-rw-r--r--arch/arm/mach-at91/board-kb9202.c2
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c2
-rw-r--r--arch/arm/mach-footbridge/cats-pci.c2
-rw-r--r--arch/arm/mach-imx/generic.c1
-rw-r--r--arch/arm/mach-ixp2000/ixdp2400.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c2
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x00.c2
-rw-r--r--arch/arm/mach-ixp23xx/ixdp2351.c2
-rw-r--r--arch/arm/mach-ixp23xx/pci.c2
-rw-r--r--arch/arm/mach-ixp23xx/roadrunner.c2
-rw-r--r--arch/arm/mach-ixp4xx/Kconfig3
-rw-r--r--arch/arm/mach-ixp4xx/common.c2
-rw-r--r--arch/arm/mach-ixp4xx/coyote-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-setup.c24
-rw-r--r--arch/arm/mach-ixp4xx/ixdpg425-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-setup.c3
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-setup.c37
-rw-r--r--arch/arm/mach-s3c2410/bast.h2
-rw-r--r--arch/arm/mach-s3c2410/mach-amlm5900.c2
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c24
-rw-r--r--arch/arm/mach-s3c2443/clock.c3
-rw-r--r--arch/arm/mach-sa1100/neponset.c4
-rw-r--r--arch/arm/mm/Kconfig5
-rw-r--r--arch/arm/mm/Makefile1
-rw-r--r--arch/arm/mm/alignment.c2
-rw-r--r--arch/arm/mm/proc-v7.S2
-rw-r--r--arch/arm/mm/tlb-v7.S88
-rw-r--r--arch/arm/nwfpe/softfloat.h3
-rw-r--r--arch/arm/oprofile/op_model_mpcore.c9
-rw-r--r--arch/h8300/kernel/sys_h8300.c4
-rw-r--r--arch/h8300/kernel/traps.c2
-rw-r--r--arch/i386/kernel/microcode.c2
-rw-r--r--arch/i386/kernel/reboot.c8
-rw-r--r--arch/i386/kernel/smpboot.c5
-rw-r--r--arch/i386/kernel/vmi.c1
-rw-r--r--arch/i386/oprofile/nmi_int.c12
-rw-r--r--arch/i386/pci/fixup.c11
-rw-r--r--arch/m68k/Kconfig13
-rw-r--r--arch/m68k/Makefile1
-rw-r--r--arch/m68k/kernel/Makefile3
-rw-r--r--arch/m68k/kernel/module.c31
-rw-r--r--arch/m68k/kernel/module.lds7
-rw-r--r--arch/m68k/kernel/setup.c37
-rw-r--r--arch/m68k/kernel/vmlinux-std.lds5
-rw-r--r--arch/m68k/kernel/vmlinux-sun3.lds5
-rw-r--r--arch/m68k/mac/debug.c2
-rw-r--r--arch/m68k/mm/init.c119
-rw-r--r--arch/m68k/mm/memory.c73
-rw-r--r--arch/m68k/mm/motorola.c104
-rw-r--r--arch/m68k/sun3/config.c2
-rw-r--r--arch/mips/jmr3927/rbhma3100/kgdb_io.c2
-rw-r--r--arch/mips/pci/pci-ocelot.c14
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/boot/dts/lite5200.dts2
-rw-r--r--arch/powerpc/boot/dts/lite5200b.dts2
-rw-r--r--arch/powerpc/mm/pgtable_32.c2
-rw-r--r--arch/powerpc/platforms/chrp/pegasos_eth.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c2
-rw-r--r--arch/powerpc/sysdev/qe_lib/Kconfig4
-rw-r--r--arch/ppc/kernel/entry.S18
-rw-r--r--arch/ppc/kernel/ppc_ksyms.c2
-rw-r--r--arch/ppc/mm/hashtable.S20
-rw-r--r--arch/ppc/mm/pgtable.c2
-rw-r--r--arch/s390/hypfs/hypfs_diag.c17
-rw-r--r--arch/s390/kernel/debug.c22
-rw-r--r--arch/s390/kernel/setup.c4
-rw-r--r--arch/s390/kernel/smp.c6
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/sh/drivers/dma/dma-api.c1
-rw-r--r--arch/sh/kernel/cf-enabler.c6
-rw-r--r--arch/sh/kernel/cpu/sh3/entry.S1
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c1
-rw-r--r--arch/sh/kernel/smp.c2
-rw-r--r--arch/sh/kernel/timers/timer.c5
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c1
-rw-r--r--arch/sparc/Kconfig7
-rw-r--r--arch/sparc/kernel/time.c4
-rw-r--r--arch/sparc/lib/atomic32.c15
-rw-r--r--arch/sparc64/Kconfig6
-rw-r--r--arch/sparc64/kernel/Makefile4
-rw-r--r--arch/sparc64/kernel/devices.c196
-rw-r--r--arch/sparc64/kernel/entry.S647
-rw-r--r--arch/sparc64/kernel/head.S31
-rw-r--r--arch/sparc64/kernel/hvapi.c5
-rw-r--r--arch/sparc64/kernel/irq.c83
-rw-r--r--arch/sparc64/kernel/itlb_miss.S4
-rw-r--r--arch/sparc64/kernel/mdesc.c619
-rw-r--r--arch/sparc64/kernel/pci.c54
-rw-r--r--arch/sparc64/kernel/pci_sabre.c7
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c54
-rw-r--r--arch/sparc64/kernel/power.c2
-rw-r--r--arch/sparc64/kernel/process.c4
-rw-r--r--arch/sparc64/kernel/prom.c148
-rw-r--r--arch/sparc64/kernel/setup.c18
-rw-r--r--arch/sparc64/kernel/smp.c155
-rw-r--r--arch/sparc64/kernel/sstate.c104
-rw-r--r--arch/sparc64/kernel/sun4v_ivec.S30
-rw-r--r--arch/sparc64/kernel/time.c47
-rw-r--r--arch/sparc64/kernel/traps.c27
-rw-r--r--arch/sparc64/kernel/vmlinux.lds.S11
-rw-r--r--arch/sparc64/mm/init.c90
-rw-r--r--arch/sparc64/prom/misc.c19
-rw-r--r--arch/x86_64/mm/init.c6
125 files changed, 2740 insertions, 969 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 770f717bd250..79c6e5a24456 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -83,22 +83,20 @@ choice
83 check out the Linux/Alpha FAQ, accessible on the WWW from 83 check out the Linux/Alpha FAQ, accessible on the WWW from
84 <http://www.alphalinux.org/>. In summary: 84 <http://www.alphalinux.org/>. In summary:
85 85
86 Alcor/Alpha-XLT AS 600 86 Alcor/Alpha-XLT AS 600, AS 500, XL-300, XL-366
87 Alpha-XL XL-233, XL-266 87 Alpha-XL XL-233, XL-266
88 AlphaBook1 Alpha laptop 88 AlphaBook1 Alpha laptop
89 Avanti AS 200, AS 205, AS 250, AS 255, AS 300, AS 400 89 Avanti AS 200, AS 205, AS 250, AS 255, AS 300, AS 400
90 Cabriolet AlphaPC64, AlphaPCI64 90 Cabriolet AlphaPC64, AlphaPCI64
91 DP264 DP264 91 DP264 DP264 / DS20 / ES40 / DS10 / DS10L
92 EB164 EB164 21164 evaluation board 92 EB164 EB164 21164 evaluation board
93 EB64+ EB64+ 21064 evaluation board 93 EB64+ EB64+ 21064 evaluation board
94 EB66 EB66 21066 evaluation board 94 EB66 EB66 21066 evaluation board
95 EB66+ EB66+ 21066 evaluation board 95 EB66+ EB66+ 21066 evaluation board
96 Jensen DECpc 150, DEC 2000 model 300, 96 Jensen DECpc 150, DEC 2000 models 300, 500
97 DEC 2000 model 500
98 LX164 AlphaPC164-LX 97 LX164 AlphaPC164-LX
99 Lynx AS 2100A 98 Lynx AS 2100A
100 Miata Personal Workstation 433a, 433au, 500a, 99 Miata Personal Workstation 433/500/600 a/au
101 500au, 600a, or 600au
102 Marvel AlphaServer ES47 / ES80 / GS1280 100 Marvel AlphaServer ES47 / ES80 / GS1280
103 Mikasa AS 1000 101 Mikasa AS 1000
104 Noname AXPpci33, UDB (Multia) 102 Noname AXPpci33, UDB (Multia)
@@ -108,9 +106,9 @@ choice
108 Ruffian RPX164-2, AlphaPC164-UX, AlphaPC164-BX 106 Ruffian RPX164-2, AlphaPC164-UX, AlphaPC164-BX
109 SX164 AlphaPC164-SX 107 SX164 AlphaPC164-SX
110 Sable AS 2000, AS 2100 108 Sable AS 2000, AS 2100
111 Shark DS 20L 109 Shark DS 20L
112 Takara Takara 110 Takara Takara (OEM)
113 Titan AlphaServer ES45 / DS25 111 Titan AlphaServer ES45 / DS25 / DS15
114 Wildfire AlphaServer GS 40/80/160/320 112 Wildfire AlphaServer GS 40/80/160/320
115 113
116 If you don't know what to do, choose "generic". 114 If you don't know what to do, choose "generic".
@@ -481,6 +479,15 @@ config ALPHA_BROKEN_IRQ_MASK
481 depends on ALPHA_GENERIC || ALPHA_PC164 479 depends on ALPHA_GENERIC || ALPHA_PC164
482 default y 480 default y
483 481
482config VGA_HOSE
483 bool
484 depends on ALPHA_GENERIC || ALPHA_TITAN || ALPHA_MARVEL || ALPHA_TSUNAMI
485 default y
486 help
487 Support VGA on an arbitrary hose; needed for several platforms
488 which always have multiple hoses, and whose consoles support it.
489
490
484config ALPHA_SRM 491config ALPHA_SRM
485 bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME 492 bool "Use SRM as bootloader" if ALPHA_CABRIOLET || ALPHA_AVANTI_CH || ALPHA_EB64P || ALPHA_PC164 || ALPHA_TAKARA || ALPHA_EB164 || ALPHA_ALCOR || ALPHA_MIATA || ALPHA_LX164 || ALPHA_SX164 || ALPHA_NAUTILUS || ALPHA_NONAME
486 default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL 493 default y if ALPHA_JENSEN || ALPHA_MIKASA || ALPHA_SABLE || ALPHA_LYNX || ALPHA_NORITAKE || ALPHA_DP264 || ALPHA_RAWHIDE || ALPHA_EIGER || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_SHARK || ALPHA_MARVEL
@@ -537,10 +544,14 @@ config HAVE_DEC_LOCK
537 default y 544 default y
538 545
539config NR_CPUS 546config NR_CPUS
540 int "Maximum number of CPUs (2-64)" 547 int "Maximum number of CPUs (2-32)"
541 range 2 64 548 range 2 32
542 depends on SMP 549 depends on SMP
543 default "64" 550 default "32" if ALPHA_GENERIC || ALPHA_MARVEL
551 default "4" if !ALPHA_GENERIC && !ALPHA_MARVEL
552 help
553 MARVEL support can handle a maximum of 32 CPUs, all the others
554 with working support have a maximum of 4 CPUs.
544 555
545config ARCH_DISCONTIGMEM_ENABLE 556config ARCH_DISCONTIGMEM_ENABLE
546 bool "Discontiguous Memory Support (EXPERIMENTAL)" 557 bool "Discontiguous Memory Support (EXPERIMENTAL)"
@@ -644,6 +655,13 @@ source "arch/alpha/oprofile/Kconfig"
644 655
645source "arch/alpha/Kconfig.debug" 656source "arch/alpha/Kconfig.debug"
646 657
658# DUMMY_CONSOLE may be defined in drivers/video/console/Kconfig
659# but we also need it if VGA_HOSE is set
660config DUMMY_CONSOLE
661 bool
662 depends on VGA_HOSE
663 default y
664
647source "security/Kconfig" 665source "security/Kconfig"
648 666
649source "crypto/Kconfig" 667source "crypto/Kconfig"
diff --git a/arch/alpha/boot/tools/mkbb.c b/arch/alpha/boot/tools/mkbb.c
index 23c7190b047c..632a7fd6d7dc 100644
--- a/arch/alpha/boot/tools/mkbb.c
+++ b/arch/alpha/boot/tools/mkbb.c
@@ -81,7 +81,7 @@ typedef union __bootblock {
81#define bootblock_label __u1.__label 81#define bootblock_label __u1.__label
82#define bootblock_checksum __u2.__checksum 82#define bootblock_checksum __u2.__checksum
83 83
84main(int argc, char ** argv) 84int main(int argc, char ** argv)
85{ 85{
86 bootblock bootblock_from_disk; 86 bootblock bootblock_from_disk;
87 bootblock bootloader_image; 87 bootblock bootloader_image;
diff --git a/arch/alpha/kernel/console.c b/arch/alpha/kernel/console.c
index f313b34939bb..da711e37fc97 100644
--- a/arch/alpha/kernel/console.c
+++ b/arch/alpha/kernel/console.c
@@ -9,16 +9,20 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/tty.h> 10#include <linux/tty.h>
11#include <linux/console.h> 11#include <linux/console.h>
12#include <linux/vt.h>
12#include <asm/vga.h> 13#include <asm/vga.h>
13#include <asm/machvec.h> 14#include <asm/machvec.h>
14 15
16#include "pci_impl.h"
17
15#ifdef CONFIG_VGA_HOSE 18#ifdef CONFIG_VGA_HOSE
16 19
17/* 20struct pci_controller *pci_vga_hose;
18 * Externally-visible vga hose bases 21static struct resource alpha_vga = {
19 */ 22 .name = "alpha-vga+",
20unsigned long __vga_hose_io_base = 0; /* base for default hose */ 23 .start = 0x3C0,
21unsigned long __vga_hose_mem_base = 0; /* base for default hose */ 24 .end = 0x3DF
25};
22 26
23static struct pci_controller * __init 27static struct pci_controller * __init
24default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2) 28default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2)
@@ -30,36 +34,58 @@ default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2)
30} 34}
31 35
32void __init 36void __init
33set_vga_hose(struct pci_controller *hose)
34{
35 if (hose) {
36 __vga_hose_io_base = hose->io_space->start;
37 __vga_hose_mem_base = hose->mem_space->start;
38 }
39}
40
41void __init
42locate_and_init_vga(void *(*sel_func)(void *, void *)) 37locate_and_init_vga(void *(*sel_func)(void *, void *))
43{ 38{
44 struct pci_controller *hose = NULL; 39 struct pci_controller *hose = NULL;
45 struct pci_dev *dev = NULL; 40 struct pci_dev *dev = NULL;
46 41
42 /* Default the select function */
47 if (!sel_func) sel_func = (void *)default_vga_hose_select; 43 if (!sel_func) sel_func = (void *)default_vga_hose_select;
48 44
45 /* Find the console VGA device */
49 for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) { 46 for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) {
50 if (!hose) hose = dev->sysdata; 47 if (!hose)
51 else hose = sel_func(hose, dev->sysdata); 48 hose = dev->sysdata;
49 else
50 hose = sel_func(hose, dev->sysdata);
52 } 51 }
53 52
54 /* Did we already inititialize the correct one? */ 53 /* Did we already initialize the correct one? Is there one? */
55 if (conswitchp == &vga_con && 54 if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose))
56 __vga_hose_io_base == hose->io_space->start &&
57 __vga_hose_mem_base == hose->mem_space->start)
58 return; 55 return;
59 56
60 /* Set the VGA hose and init the new console */ 57 /* Create a new VGA ioport resource WRT the hose it is on. */
61 set_vga_hose(hose); 58 alpha_vga.start += hose->io_space->start;
59 alpha_vga.end += hose->io_space->start;
60 request_resource(hose->io_space, &alpha_vga);
61
62 /* Set the VGA hose and init the new console. */
63 pci_vga_hose = hose;
62 take_over_console(&vga_con, 0, MAX_NR_CONSOLES-1, 1); 64 take_over_console(&vga_con, 0, MAX_NR_CONSOLES-1, 1);
63} 65}
64 66
67void __init
68find_console_vga_hose(void)
69{
70 u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
71
72 if (pu64[7] == 3) { /* TERM_TYPE == graphics */
73 struct pci_controller *hose;
74 int h = (pu64[30] >> 24) & 0xff; /* console hose # */
75
76 /*
77 * Our hose numbering DOES match the console's, so find
78 * the right one...
79 */
80 for (hose = hose_head; hose; hose = hose->next) {
81 if (hose->index == h) break;
82 }
83
84 if (hose) {
85 printk("Console graphics on hose %d\n", h);
86 pci_vga_hose = hose;
87 }
88 }
89}
90
65#endif 91#endif
diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
index 7f6a98455e74..f10d2eddd2c3 100644
--- a/arch/alpha/kernel/core_marvel.c
+++ b/arch/alpha/kernel/core_marvel.c
@@ -25,6 +25,7 @@
25#include <asm/pgalloc.h> 25#include <asm/pgalloc.h>
26#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
27#include <asm/rtc.h> 27#include <asm/rtc.h>
28#include <asm/vga.h>
28 29
29#include "proto.h" 30#include "proto.h"
30#include "pci_impl.h" 31#include "pci_impl.h"
@@ -367,9 +368,8 @@ marvel_io7_present(gct6_node *node)
367} 368}
368 369
369static void __init 370static void __init
370marvel_init_vga_hose(void) 371marvel_find_console_vga_hose(void)
371{ 372{
372#ifdef CONFIG_VGA_HOSE
373 u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset); 373 u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
374 374
375 if (pu64[7] == 3) { /* TERM_TYPE == graphics */ 375 if (pu64[7] == 3) { /* TERM_TYPE == graphics */
@@ -403,7 +403,6 @@ marvel_init_vga_hose(void)
403 pci_vga_hose = hose; 403 pci_vga_hose = hose;
404 } 404 }
405 } 405 }
406#endif /* CONFIG_VGA_HOSE */
407} 406}
408 407
409gct6_search_struct gct_wanted_node_list[] = { 408gct6_search_struct gct_wanted_node_list[] = {
@@ -459,7 +458,7 @@ marvel_init_arch(void)
459 marvel_init_io7(io7); 458 marvel_init_io7(io7);
460 459
461 /* Check for graphic console location (if any). */ 460 /* Check for graphic console location (if any). */
462 marvel_init_vga_hose(); 461 marvel_find_console_vga_hose();
463} 462}
464 463
465void 464void
@@ -684,9 +683,6 @@ __marvel_rtc_io(u8 b, unsigned long addr, int write)
684/* 683/*
685 * IO map support. 684 * IO map support.
686 */ 685 */
687
688#define __marvel_is_mem_vga(a) (((a) >= 0xa0000) && ((a) <= 0xc0000))
689
690void __iomem * 686void __iomem *
691marvel_ioremap(unsigned long addr, unsigned long size) 687marvel_ioremap(unsigned long addr, unsigned long size)
692{ 688{
@@ -698,13 +694,9 @@ marvel_ioremap(unsigned long addr, unsigned long size)
698 unsigned long pfn; 694 unsigned long pfn;
699 695
700 /* 696 /*
701 * Adjust the addr. 697 * Adjust the address.
702 */ 698 */
703#ifdef CONFIG_VGA_HOSE 699 FIXUP_MEMADDR_VGA(addr);
704 if (pci_vga_hose && __marvel_is_mem_vga(addr)) {
705 addr += pci_vga_hose->mem_space->start;
706 }
707#endif
708 700
709 /* 701 /*
710 * Find the hose. 702 * Find the hose.
@@ -781,7 +773,9 @@ marvel_ioremap(unsigned long addr, unsigned long size)
781 return (void __iomem *) vaddr; 773 return (void __iomem *) vaddr;
782 } 774 }
783 775
784 return NULL; 776 /* Assume it was already a reasonable address */
777 vaddr = baddr + hose->mem_space->start;
778 return (void __iomem *) vaddr;
785} 779}
786 780
787void 781void
@@ -803,21 +797,12 @@ marvel_is_mmio(const volatile void __iomem *xaddr)
803 return (addr & 0xFF000000UL) == 0; 797 return (addr & 0xFF000000UL) == 0;
804} 798}
805 799
806#define __marvel_is_port_vga(a) \
807 (((a) >= 0x3b0) && ((a) < 0x3e0) && ((a) != 0x3b3) && ((a) != 0x3d3))
808#define __marvel_is_port_kbd(a) (((a) == 0x60) || ((a) == 0x64)) 800#define __marvel_is_port_kbd(a) (((a) == 0x60) || ((a) == 0x64))
809#define __marvel_is_port_rtc(a) (((a) == 0x70) || ((a) == 0x71)) 801#define __marvel_is_port_rtc(a) (((a) == 0x70) || ((a) == 0x71))
810 802
811void __iomem *marvel_ioportmap (unsigned long addr) 803void __iomem *marvel_ioportmap (unsigned long addr)
812{ 804{
813 if (__marvel_is_port_rtc (addr) || __marvel_is_port_kbd(addr)) 805 FIXUP_IOADDR_VGA(addr);
814 ;
815#ifdef CONFIG_VGA_HOSE
816 else if (__marvel_is_port_vga (addr) && pci_vga_hose)
817 addr += pci_vga_hose->io_space->start;
818#endif
819 else
820 return NULL;
821 return (void __iomem *)addr; 806 return (void __iomem *)addr;
822} 807}
823 808
@@ -829,8 +814,14 @@ marvel_ioread8(void __iomem *xaddr)
829 return 0; 814 return 0;
830 else if (__marvel_is_port_rtc(addr)) 815 else if (__marvel_is_port_rtc(addr))
831 return __marvel_rtc_io(0, addr, 0); 816 return __marvel_rtc_io(0, addr, 0);
832 else 817 else if (marvel_is_ioaddr(addr))
833 return __kernel_ldbu(*(vucp)addr); 818 return __kernel_ldbu(*(vucp)addr);
819 else
820 /* this should catch other legacy addresses
821 that would normally fail on MARVEL,
822 because there really is nothing there...
823 */
824 return ~0;
834} 825}
835 826
836void 827void
@@ -841,7 +832,7 @@ marvel_iowrite8(u8 b, void __iomem *xaddr)
841 return; 832 return;
842 else if (__marvel_is_port_rtc(addr)) 833 else if (__marvel_is_port_rtc(addr))
843 __marvel_rtc_io(b, addr, 1); 834 __marvel_rtc_io(b, addr, 1);
844 else 835 else if (marvel_is_ioaddr(addr))
845 __kernel_stb(b, *(vucp)addr); 836 __kernel_stb(b, *(vucp)addr);
846} 837}
847 838
diff --git a/arch/alpha/kernel/core_titan.c b/arch/alpha/kernel/core_titan.c
index 3662fef7db9a..819326627b96 100644
--- a/arch/alpha/kernel/core_titan.c
+++ b/arch/alpha/kernel/core_titan.c
@@ -21,6 +21,7 @@
21#include <asm/smp.h> 21#include <asm/smp.h>
22#include <asm/pgalloc.h> 22#include <asm/pgalloc.h>
23#include <asm/tlbflush.h> 23#include <asm/tlbflush.h>
24#include <asm/vga.h>
24 25
25#include "proto.h" 26#include "proto.h"
26#include "pci_impl.h" 27#include "pci_impl.h"
@@ -35,6 +36,11 @@ struct
35} saved_config[4] __attribute__((common)); 36} saved_config[4] __attribute__((common));
36 37
37/* 38/*
39 * Is PChip 1 present? No need to query it more than once.
40 */
41static int titan_pchip1_present;
42
43/*
38 * BIOS32-style PCI interface: 44 * BIOS32-style PCI interface:
39 */ 45 */
40 46
@@ -344,43 +350,17 @@ titan_init_one_pachip_port(titan_pachip_port *port, int index)
344static void __init 350static void __init
345titan_init_pachips(titan_pachip *pachip0, titan_pachip *pachip1) 351titan_init_pachips(titan_pachip *pachip0, titan_pachip *pachip1)
346{ 352{
347 int pchip1_present = TITAN_cchip->csc.csr & 1L<<14; 353 titan_pchip1_present = TITAN_cchip->csc.csr & 1L<<14;
348 354
349 /* Init the ports in hose order... */ 355 /* Init the ports in hose order... */
350 titan_init_one_pachip_port(&pachip0->g_port, 0); /* hose 0 */ 356 titan_init_one_pachip_port(&pachip0->g_port, 0); /* hose 0 */
351 if (pchip1_present) 357 if (titan_pchip1_present)
352 titan_init_one_pachip_port(&pachip1->g_port, 1);/* hose 1 */ 358 titan_init_one_pachip_port(&pachip1->g_port, 1);/* hose 1 */
353 titan_init_one_pachip_port(&pachip0->a_port, 2); /* hose 2 */ 359 titan_init_one_pachip_port(&pachip0->a_port, 2); /* hose 2 */
354 if (pchip1_present) 360 if (titan_pchip1_present)
355 titan_init_one_pachip_port(&pachip1->a_port, 3);/* hose 3 */ 361 titan_init_one_pachip_port(&pachip1->a_port, 3);/* hose 3 */
356} 362}
357 363
358static void __init
359titan_init_vga_hose(void)
360{
361#ifdef CONFIG_VGA_HOSE
362 u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
363
364 if (pu64[7] == 3) { /* TERM_TYPE == graphics */
365 struct pci_controller *hose;
366 int h = (pu64[30] >> 24) & 0xff; /* console hose # */
367
368 /*
369 * Our hose numbering matches the console's, so just find
370 * the right one...
371 */
372 for (hose = hose_head; hose; hose = hose->next) {
373 if (hose->index == h) break;
374 }
375
376 if (hose) {
377 printk("Console graphics on hose %d\n", hose->index);
378 pci_vga_hose = hose;
379 }
380 }
381#endif /* CONFIG_VGA_HOSE */
382}
383
384void __init 364void __init
385titan_init_arch(void) 365titan_init_arch(void)
386{ 366{
@@ -406,6 +386,7 @@ titan_init_arch(void)
406 386
407 /* With multiple PCI busses, we play with I/O as physical addrs. */ 387 /* With multiple PCI busses, we play with I/O as physical addrs. */
408 ioport_resource.end = ~0UL; 388 ioport_resource.end = ~0UL;
389 iomem_resource.end = ~0UL;
409 390
410 /* PCI DMA Direct Mapping is 1GB at 2GB. */ 391 /* PCI DMA Direct Mapping is 1GB at 2GB. */
411 __direct_map_base = 0x80000000; 392 __direct_map_base = 0x80000000;
@@ -415,7 +396,7 @@ titan_init_arch(void)
415 titan_init_pachips(TITAN_pachip0, TITAN_pachip1); 396 titan_init_pachips(TITAN_pachip0, TITAN_pachip1);
416 397
417 /* Check for graphic console location (if any). */ 398 /* Check for graphic console location (if any). */
418 titan_init_vga_hose(); 399 find_console_vga_hose();
419} 400}
420 401
421static void 402static void
@@ -441,9 +422,7 @@ titan_kill_one_pachip_port(titan_pachip_port *port, int index)
441static void 422static void
442titan_kill_pachips(titan_pachip *pachip0, titan_pachip *pachip1) 423titan_kill_pachips(titan_pachip *pachip0, titan_pachip *pachip1)
443{ 424{
444 int pchip1_present = TITAN_cchip->csc.csr & 1L<<14; 425 if (titan_pchip1_present) {
445
446 if (pchip1_present) {
447 titan_kill_one_pachip_port(&pachip1->g_port, 1); 426 titan_kill_one_pachip_port(&pachip1->g_port, 1);
448 titan_kill_one_pachip_port(&pachip1->a_port, 3); 427 titan_kill_one_pachip_port(&pachip1->a_port, 3);
449 } 428 }
@@ -463,6 +442,14 @@ titan_kill_arch(int mode)
463 */ 442 */
464 443
465void __iomem * 444void __iomem *
445titan_ioportmap(unsigned long addr)
446{
447 FIXUP_IOADDR_VGA(addr);
448 return (void __iomem *)(addr + TITAN_IO_BIAS);
449}
450
451
452void __iomem *
466titan_ioremap(unsigned long addr, unsigned long size) 453titan_ioremap(unsigned long addr, unsigned long size)
467{ 454{
468 int h = (addr & TITAN_HOSE_MASK) >> TITAN_HOSE_SHIFT; 455 int h = (addr & TITAN_HOSE_MASK) >> TITAN_HOSE_SHIFT;
@@ -475,14 +462,12 @@ titan_ioremap(unsigned long addr, unsigned long size)
475 unsigned long pfn; 462 unsigned long pfn;
476 463
477 /* 464 /*
478 * Adjust the addr. 465 * Adjust the address and hose, if necessary.
479 */ 466 */
480#ifdef CONFIG_VGA_HOSE 467 if (pci_vga_hose && __is_mem_vga(addr)) {
481 if (pci_vga_hose && __titan_is_mem_vga(addr)) {
482 h = pci_vga_hose->index; 468 h = pci_vga_hose->index;
483 addr += pci_vga_hose->mem_space->start; 469 addr += pci_vga_hose->mem_space->start;
484 } 470 }
485#endif
486 471
487 /* 472 /*
488 * Find the hose. 473 * Find the hose.
@@ -521,8 +506,10 @@ titan_ioremap(unsigned long addr, unsigned long size)
521 * Map it 506 * Map it
522 */ 507 */
523 area = get_vm_area(size, VM_IOREMAP); 508 area = get_vm_area(size, VM_IOREMAP);
524 if (!area) 509 if (!area) {
510 printk("ioremap failed... no vm_area...\n");
525 return NULL; 511 return NULL;
512 }
526 513
527 ptes = hose->sg_pci->ptes; 514 ptes = hose->sg_pci->ptes;
528 for (vaddr = (unsigned long)area->addr; 515 for (vaddr = (unsigned long)area->addr;
@@ -539,7 +526,7 @@ titan_ioremap(unsigned long addr, unsigned long size)
539 if (__alpha_remap_area_pages(vaddr, 526 if (__alpha_remap_area_pages(vaddr,
540 pfn << PAGE_SHIFT, 527 pfn << PAGE_SHIFT,
541 PAGE_SIZE, 0)) { 528 PAGE_SIZE, 0)) {
542 printk("FAILED to map...\n"); 529 printk("FAILED to remap_area_pages...\n");
543 vfree(area->addr); 530 vfree(area->addr);
544 return NULL; 531 return NULL;
545 } 532 }
@@ -551,7 +538,8 @@ titan_ioremap(unsigned long addr, unsigned long size)
551 return (void __iomem *) vaddr; 538 return (void __iomem *) vaddr;
552 } 539 }
553 540
554 return NULL; 541 /* Assume a legacy (read: VGA) address, and return appropriately. */
542 return (void __iomem *)(addr + TITAN_MEM_BIAS);
555} 543}
556 544
557void 545void
@@ -574,6 +562,7 @@ titan_is_mmio(const volatile void __iomem *xaddr)
574} 562}
575 563
576#ifndef CONFIG_ALPHA_GENERIC 564#ifndef CONFIG_ALPHA_GENERIC
565EXPORT_SYMBOL(titan_ioportmap);
577EXPORT_SYMBOL(titan_ioremap); 566EXPORT_SYMBOL(titan_ioremap);
578EXPORT_SYMBOL(titan_iounmap); 567EXPORT_SYMBOL(titan_iounmap);
579EXPORT_SYMBOL(titan_is_mmio); 568EXPORT_SYMBOL(titan_is_mmio);
@@ -750,6 +739,7 @@ titan_agp_info(void)
750 if (titan_query_agp(port)) 739 if (titan_query_agp(port))
751 hosenum = 2; 740 hosenum = 2;
752 if (hosenum < 0 && 741 if (hosenum < 0 &&
742 titan_pchip1_present &&
753 titan_query_agp(port = &TITAN_pachip1->a_port)) 743 titan_query_agp(port = &TITAN_pachip1->a_port))
754 hosenum = 3; 744 hosenum = 3;
755 745
diff --git a/arch/alpha/kernel/core_tsunami.c b/arch/alpha/kernel/core_tsunami.c
index ce623c6e55e1..ef91e09590d4 100644
--- a/arch/alpha/kernel/core_tsunami.c
+++ b/arch/alpha/kernel/core_tsunami.c
@@ -19,6 +19,7 @@
19 19
20#include <asm/ptrace.h> 20#include <asm/ptrace.h>
21#include <asm/smp.h> 21#include <asm/smp.h>
22#include <asm/vga.h>
22 23
23#include "proto.h" 24#include "proto.h"
24#include "pci_impl.h" 25#include "pci_impl.h"
@@ -349,6 +350,26 @@ tsunami_init_one_pchip(tsunami_pchip *pchip, int index)
349 tsunami_pci_tbi(hose, 0, -1); 350 tsunami_pci_tbi(hose, 0, -1);
350} 351}
351 352
353
354void __iomem *
355tsunami_ioportmap(unsigned long addr)
356{
357 FIXUP_IOADDR_VGA(addr);
358 return (void __iomem *)(addr + TSUNAMI_IO_BIAS);
359}
360
361void __iomem *
362tsunami_ioremap(unsigned long addr, unsigned long size)
363{
364 FIXUP_MEMADDR_VGA(addr);
365 return (void __iomem *)(addr + TSUNAMI_MEM_BIAS);
366}
367
368#ifndef CONFIG_ALPHA_GENERIC
369EXPORT_SYMBOL(tsunami_ioportmap);
370EXPORT_SYMBOL(tsunami_ioremap);
371#endif
372
352void __init 373void __init
353tsunami_init_arch(void) 374tsunami_init_arch(void)
354{ 375{
@@ -393,6 +414,9 @@ tsunami_init_arch(void)
393 tsunami_init_one_pchip(TSUNAMI_pchip0, 0); 414 tsunami_init_one_pchip(TSUNAMI_pchip0, 0);
394 if (TSUNAMI_cchip->csc.csr & 1L<<14) 415 if (TSUNAMI_cchip->csc.csr & 1L<<14)
395 tsunami_init_one_pchip(TSUNAMI_pchip1, 1); 416 tsunami_init_one_pchip(TSUNAMI_pchip1, 1);
417
418 /* Check for graphic console location (if any). */
419 find_console_vga_hose();
396} 420}
397 421
398static void 422static void
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index c95e95e1ab04..debc8f03886c 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -391,11 +391,10 @@ $work_resched:
391 bne $2, $work_resched 391 bne $2, $work_resched
392 392
393$work_notifysig: 393$work_notifysig:
394 mov $sp, $17 394 mov $sp, $16
395 br $1, do_switch_stack 395 br $1, do_switch_stack
396 mov $5, $21 396 mov $sp, $17
397 mov $sp, $18 397 mov $5, $18
398 mov $31, $16
399 jsr $26, do_notify_resume 398 jsr $26, do_notify_resume
400 bsr $1, undo_switch_stack 399 bsr $1, undo_switch_stack
401 br restore_all 400 br restore_all
diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index 6e7d1fe6e935..28c84e55feb9 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -7,6 +7,7 @@
7#include <linux/pci.h> 7#include <linux/pci.h>
8#include <linux/slab.h> 8#include <linux/slab.h>
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/log2.h>
10 11
11#include <asm/io.h> 12#include <asm/io.h>
12#include <asm/hwrpb.h> 13#include <asm/hwrpb.h>
@@ -53,7 +54,7 @@ size_for_memory(unsigned long max)
53{ 54{
54 unsigned long mem = max_low_pfn << PAGE_SHIFT; 55 unsigned long mem = max_low_pfn << PAGE_SHIFT;
55 if (mem < max) 56 if (mem < max)
56 max = 1UL << ceil_log2(mem); 57 max = roundup_pow_of_two(mem);
57 return max; 58 return max;
58} 59}
59 60
diff --git a/arch/alpha/kernel/proto.h b/arch/alpha/kernel/proto.h
index 95912ecc65e1..708d5ca87782 100644
--- a/arch/alpha/kernel/proto.h
+++ b/arch/alpha/kernel/proto.h
@@ -108,6 +108,15 @@ extern int wildfire_cpuid_to_nid(int);
108extern unsigned long wildfire_node_mem_start(int); 108extern unsigned long wildfire_node_mem_start(int);
109extern unsigned long wildfire_node_mem_size(int); 109extern unsigned long wildfire_node_mem_size(int);
110 110
111/* console.c */
112#ifdef CONFIG_VGA_HOSE
113extern void find_console_vga_hose(void);
114extern void locate_and_init_vga(void *(*)(void *, void *));
115#else
116static inline void find_console_vga_hose(void) { }
117static inline void locate_and_init_vga(void *(*sel_func)(void *, void *)) { }
118#endif
119
111/* setup.c */ 120/* setup.c */
112extern unsigned long srm_hae; 121extern unsigned long srm_hae;
113extern int boot_cpuid; 122extern int boot_cpuid;
diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c
index 915f26345c45..bd5e68cd61e8 100644
--- a/arch/alpha/kernel/setup.c
+++ b/arch/alpha/kernel/setup.c
@@ -43,6 +43,7 @@
43#include <linux/notifier.h> 43#include <linux/notifier.h>
44#include <asm/setup.h> 44#include <asm/setup.h>
45#include <asm/io.h> 45#include <asm/io.h>
46#include <linux/log2.h>
46 47
47extern struct atomic_notifier_head panic_notifier_list; 48extern struct atomic_notifier_head panic_notifier_list;
48static int alpha_panic_event(struct notifier_block *, unsigned long, void *); 49static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
@@ -1303,7 +1304,7 @@ external_cache_probe(int minsize, int width)
1303 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2; 1304 long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
1304 1305
1305 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT) 1306 if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
1306 maxsize = 1 << (floor_log2(max_low_pfn + 1) + PAGE_SHIFT); 1307 maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
1307 1308
1308 /* Get the first block cached. */ 1309 /* Get the first block cached. */
1309 read_mem_block(__va(0), stride, size); 1310 read_mem_block(__va(0), stride, size);
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index 7f64aa767d5a..410af4f3140e 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -32,8 +32,8 @@
32#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 32#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
33 33
34asmlinkage void ret_from_sys_call(void); 34asmlinkage void ret_from_sys_call(void);
35static int do_signal(sigset_t *, struct pt_regs *, struct switch_stack *, 35static void do_signal(struct pt_regs *, struct switch_stack *,
36 unsigned long, unsigned long); 36 unsigned long, unsigned long);
37 37
38 38
39/* 39/*
@@ -146,11 +146,9 @@ sys_rt_sigaction(int sig, const struct sigaction __user *act,
146asmlinkage int 146asmlinkage int
147do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw) 147do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw)
148{ 148{
149 sigset_t oldset;
150
151 mask &= _BLOCKABLE; 149 mask &= _BLOCKABLE;
152 spin_lock_irq(&current->sighand->siglock); 150 spin_lock_irq(&current->sighand->siglock);
153 oldset = current->blocked; 151 current->saved_sigmask = current->blocked;
154 siginitset(&current->blocked, mask); 152 siginitset(&current->blocked, mask);
155 recalc_sigpending(); 153 recalc_sigpending();
156 spin_unlock_irq(&current->sighand->siglock); 154 spin_unlock_irq(&current->sighand->siglock);
@@ -160,19 +158,17 @@ do_sigsuspend(old_sigset_t mask, struct pt_regs *regs, struct switch_stack *sw)
160 regs->r0 = EINTR; 158 regs->r0 = EINTR;
161 regs->r19 = 1; 159 regs->r19 = 1;
162 160
163 while (1) { 161 current->state = TASK_INTERRUPTIBLE;
164 current->state = TASK_INTERRUPTIBLE; 162 schedule();
165 schedule(); 163 set_thread_flag(TIF_RESTORE_SIGMASK);
166 if (do_signal(&oldset, regs, sw, 0, 0)) 164 return -ERESTARTNOHAND;
167 return -EINTR;
168 }
169} 165}
170 166
171asmlinkage int 167asmlinkage int
172do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize, 168do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize,
173 struct pt_regs *regs, struct switch_stack *sw) 169 struct pt_regs *regs, struct switch_stack *sw)
174{ 170{
175 sigset_t oldset, set; 171 sigset_t set;
176 172
177 /* XXX: Don't preclude handling different sized sigset_t's. */ 173 /* XXX: Don't preclude handling different sized sigset_t's. */
178 if (sigsetsize != sizeof(sigset_t)) 174 if (sigsetsize != sizeof(sigset_t))
@@ -182,7 +178,7 @@ do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize,
182 178
183 sigdelsetmask(&set, ~_BLOCKABLE); 179 sigdelsetmask(&set, ~_BLOCKABLE);
184 spin_lock_irq(&current->sighand->siglock); 180 spin_lock_irq(&current->sighand->siglock);
185 oldset = current->blocked; 181 current->saved_sigmask = current->blocked;
186 current->blocked = set; 182 current->blocked = set;
187 recalc_sigpending(); 183 recalc_sigpending();
188 spin_unlock_irq(&current->sighand->siglock); 184 spin_unlock_irq(&current->sighand->siglock);
@@ -192,12 +188,10 @@ do_rt_sigsuspend(sigset_t __user *uset, size_t sigsetsize,
192 regs->r0 = EINTR; 188 regs->r0 = EINTR;
193 regs->r19 = 1; 189 regs->r19 = 1;
194 190
195 while (1) { 191 current->state = TASK_INTERRUPTIBLE;
196 current->state = TASK_INTERRUPTIBLE; 192 schedule();
197 schedule(); 193 set_thread_flag(TIF_RESTORE_SIGMASK);
198 if (do_signal(&oldset, regs, sw, 0, 0)) 194 return -ERESTARTNOHAND;
199 return -EINTR;
200 }
201} 195}
202 196
203asmlinkage int 197asmlinkage int
@@ -436,7 +430,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
436 return err; 430 return err;
437} 431}
438 432
439static void 433static int
440setup_frame(int sig, struct k_sigaction *ka, sigset_t *set, 434setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
441 struct pt_regs *regs, struct switch_stack * sw) 435 struct pt_regs *regs, struct switch_stack * sw)
442{ 436{
@@ -481,13 +475,14 @@ setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
481 current->comm, current->pid, frame, regs->pc, regs->r26); 475 current->comm, current->pid, frame, regs->pc, regs->r26);
482#endif 476#endif
483 477
484 return; 478 return 0;
485 479
486give_sigsegv: 480give_sigsegv:
487 force_sigsegv(sig, current); 481 force_sigsegv(sig, current);
482 return -EFAULT;
488} 483}
489 484
490static void 485static int
491setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 486setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
492 sigset_t *set, struct pt_regs *regs, struct switch_stack * sw) 487 sigset_t *set, struct pt_regs *regs, struct switch_stack * sw)
493{ 488{
@@ -543,34 +538,38 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
543 current->comm, current->pid, frame, regs->pc, regs->r26); 538 current->comm, current->pid, frame, regs->pc, regs->r26);
544#endif 539#endif
545 540
546 return; 541 return 0;
547 542
548give_sigsegv: 543give_sigsegv:
549 force_sigsegv(sig, current); 544 force_sigsegv(sig, current);
545 return -EFAULT;
550} 546}
551 547
552 548
553/* 549/*
554 * OK, we're invoking a handler. 550 * OK, we're invoking a handler.
555 */ 551 */
556static inline void 552static inline int
557handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info, 553handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
558 sigset_t *oldset, struct pt_regs * regs, struct switch_stack *sw) 554 sigset_t *oldset, struct pt_regs * regs, struct switch_stack *sw)
559{ 555{
556 int ret;
557
560 if (ka->sa.sa_flags & SA_SIGINFO) 558 if (ka->sa.sa_flags & SA_SIGINFO)
561 setup_rt_frame(sig, ka, info, oldset, regs, sw); 559 ret = setup_rt_frame(sig, ka, info, oldset, regs, sw);
562 else 560 else
563 setup_frame(sig, ka, oldset, regs, sw); 561 ret = setup_frame(sig, ka, oldset, regs, sw);
564 562
565 if (ka->sa.sa_flags & SA_RESETHAND) 563 if (ret == 0) {
566 ka->sa.sa_handler = SIG_DFL; 564 spin_lock_irq(&current->sighand->siglock);
565 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
566 if (!(ka->sa.sa_flags & SA_NODEFER))
567 sigaddset(&current->blocked,sig);
568 recalc_sigpending();
569 spin_unlock_irq(&current->sighand->siglock);
570 }
567 571
568 spin_lock_irq(&current->sighand->siglock); 572 return ret;
569 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
570 if (!(ka->sa.sa_flags & SA_NODEFER))
571 sigaddset(&current->blocked,sig);
572 recalc_sigpending();
573 spin_unlock_irq(&current->sighand->siglock);
574} 573}
575 574
576static inline void 575static inline void
@@ -611,30 +610,42 @@ syscall_restart(unsigned long r0, unsigned long r19,
611 * restart. "r0" is also used as an indicator whether we can restart at 610 * restart. "r0" is also used as an indicator whether we can restart at
612 * all (if we get here from anything but a syscall return, it will be 0) 611 * all (if we get here from anything but a syscall return, it will be 0)
613 */ 612 */
614static int 613static void
615do_signal(sigset_t *oldset, struct pt_regs * regs, struct switch_stack * sw, 614do_signal(struct pt_regs * regs, struct switch_stack * sw,
616 unsigned long r0, unsigned long r19) 615 unsigned long r0, unsigned long r19)
617{ 616{
618 siginfo_t info; 617 siginfo_t info;
619 int signr; 618 int signr;
620 unsigned long single_stepping = ptrace_cancel_bpt(current); 619 unsigned long single_stepping = ptrace_cancel_bpt(current);
621 struct k_sigaction ka; 620 struct k_sigaction ka;
621 sigset_t *oldset;
622 622
623 if (!oldset) 623 if (test_thread_flag(TIF_RESTORE_SIGMASK))
624 oldset = &current->saved_sigmask;
625 else
624 oldset = &current->blocked; 626 oldset = &current->blocked;
625 627
626 /* This lets the debugger run, ... */ 628 /* This lets the debugger run, ... */
627 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 629 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
630
628 /* ... so re-check the single stepping. */ 631 /* ... so re-check the single stepping. */
629 single_stepping |= ptrace_cancel_bpt(current); 632 single_stepping |= ptrace_cancel_bpt(current);
630 633
631 if (signr > 0) { 634 if (signr > 0) {
632 /* Whee! Actually deliver the signal. */ 635 /* Whee! Actually deliver the signal. */
633 if (r0) syscall_restart(r0, r19, regs, &ka); 636 if (r0)
634 handle_signal(signr, &ka, &info, oldset, regs, sw); 637 syscall_restart(r0, r19, regs, &ka);
638 if (handle_signal(signr, &ka, &info, oldset, regs, sw) == 0) {
639 /* A signal was successfully delivered, and the
640 saved sigmask was stored on the signal frame,
641 and will be restored by sigreturn. So we can
642 simply clear the restore sigmask flag. */
643 if (test_thread_flag(TIF_RESTORE_SIGMASK))
644 clear_thread_flag(TIF_RESTORE_SIGMASK);
645 }
635 if (single_stepping) 646 if (single_stepping)
636 ptrace_set_bpt(current); /* re-set bpt */ 647 ptrace_set_bpt(current); /* re-set bpt */
637 return 1; 648 return;
638 } 649 }
639 650
640 if (r0) { 651 if (r0) {
@@ -654,17 +665,22 @@ do_signal(sigset_t *oldset, struct pt_regs * regs, struct switch_stack * sw,
654 break; 665 break;
655 } 666 }
656 } 667 }
668
669 /* If there's no signal to deliver, we just restore the saved mask. */
670 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
671 clear_thread_flag(TIF_RESTORE_SIGMASK);
672 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
673 }
674
657 if (single_stepping) 675 if (single_stepping)
658 ptrace_set_bpt(current); /* re-set breakpoint */ 676 ptrace_set_bpt(current); /* re-set breakpoint */
659
660 return 0;
661} 677}
662 678
663void 679void
664do_notify_resume(sigset_t *oldset, struct pt_regs *regs, 680do_notify_resume(struct pt_regs *regs, struct switch_stack *sw,
665 struct switch_stack *sw, unsigned long r0, 681 unsigned long thread_info_flags,
666 unsigned long r19, unsigned long thread_info_flags) 682 unsigned long r0, unsigned long r19)
667{ 683{
668 if (thread_info_flags & _TIF_SIGPENDING) 684 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
669 do_signal(oldset, regs, sw, r0, r19); 685 do_signal(regs, sw, r0, r19);
670} 686}
diff --git a/arch/alpha/kernel/sys_dp264.c b/arch/alpha/kernel/sys_dp264.c
index 85d2f933dd07..c71b0fd7a61f 100644
--- a/arch/alpha/kernel/sys_dp264.c
+++ b/arch/alpha/kernel/sys_dp264.c
@@ -543,6 +543,7 @@ dp264_init_pci(void)
543{ 543{
544 common_init_pci(); 544 common_init_pci();
545 SMC669_Init(0); 545 SMC669_Init(0);
546 locate_and_init_vga(NULL);
546} 547}
547 548
548static void __init 549static void __init
@@ -551,6 +552,14 @@ monet_init_pci(void)
551 common_init_pci(); 552 common_init_pci();
552 SMC669_Init(1); 553 SMC669_Init(1);
553 es1888_init(); 554 es1888_init();
555 locate_and_init_vga(NULL);
556}
557
558static void __init
559clipper_init_pci(void)
560{
561 common_init_pci();
562 locate_and_init_vga(NULL);
554} 563}
555 564
556static void __init 565static void __init
@@ -655,7 +664,7 @@ struct alpha_machine_vector clipper_mv __initmv = {
655 .init_arch = tsunami_init_arch, 664 .init_arch = tsunami_init_arch,
656 .init_irq = clipper_init_irq, 665 .init_irq = clipper_init_irq,
657 .init_rtc = common_init_rtc, 666 .init_rtc = common_init_rtc,
658 .init_pci = common_init_pci, 667 .init_pci = clipper_init_pci,
659 .kill_arch = tsunami_kill_arch, 668 .kill_arch = tsunami_kill_arch,
660 .pci_map_irq = clipper_map_irq, 669 .pci_map_irq = clipper_map_irq,
661 .pci_swizzle = common_swizzle, 670 .pci_swizzle = common_swizzle,
diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
index e349f03b830e..0bcb968cb60a 100644
--- a/arch/alpha/kernel/sys_marvel.c
+++ b/arch/alpha/kernel/sys_marvel.c
@@ -22,6 +22,7 @@
22#include <asm/core_marvel.h> 22#include <asm/core_marvel.h>
23#include <asm/hwrpb.h> 23#include <asm/hwrpb.h>
24#include <asm/tlbflush.h> 24#include <asm/tlbflush.h>
25#include <asm/vga.h>
25 26
26#include "proto.h" 27#include "proto.h"
27#include "err_impl.h" 28#include "err_impl.h"
@@ -412,10 +413,7 @@ marvel_init_pci(void)
412 413
413 pci_probe_only = 1; 414 pci_probe_only = 1;
414 common_init_pci(); 415 common_init_pci();
415
416#ifdef CONFIG_VGA_HOSE
417 locate_and_init_vga(NULL); 416 locate_and_init_vga(NULL);
418#endif
419 417
420 /* Clear any io7 errors. */ 418 /* Clear any io7 errors. */
421 for (io7 = NULL; (io7 = marvel_next_io7(io7)) != NULL; ) 419 for (io7 = NULL; (io7 = marvel_next_io7(io7)) != NULL; )
diff --git a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c
index f009b7bc0943..1d3c1398c428 100644
--- a/arch/alpha/kernel/sys_titan.c
+++ b/arch/alpha/kernel/sys_titan.c
@@ -331,9 +331,7 @@ titan_init_pci(void)
331 pci_probe_only = 1; 331 pci_probe_only = 1;
332 common_init_pci(); 332 common_init_pci();
333 SMC669_Init(0); 333 SMC669_Init(0);
334#ifdef CONFIG_VGA_HOSE
335 locate_and_init_vga(NULL); 334 locate_and_init_vga(NULL);
336#endif
337} 335}
338 336
339 337
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S
index f6cfe8ce3f96..79de99e32c35 100644
--- a/arch/alpha/kernel/systbls.S
+++ b/arch/alpha/kernel/systbls.S
@@ -465,6 +465,38 @@ sys_call_table:
465 .quad sys_inotify_init 465 .quad sys_inotify_init
466 .quad sys_inotify_add_watch /* 445 */ 466 .quad sys_inotify_add_watch /* 445 */
467 .quad sys_inotify_rm_watch 467 .quad sys_inotify_rm_watch
468 .quad sys_fdatasync
469 .quad sys_kexec_load
470 .quad sys_migrate_pages
471 .quad sys_openat /* 450 */
472 .quad sys_mkdirat
473 .quad sys_mknodat
474 .quad sys_fchownat
475 .quad sys_futimesat
476 .quad sys_fstatat64 /* 455 */
477 .quad sys_unlinkat
478 .quad sys_renameat
479 .quad sys_linkat
480 .quad sys_symlinkat
481 .quad sys_readlinkat /* 460 */
482 .quad sys_fchmodat
483 .quad sys_faccessat
484 .quad sys_pselect6
485 .quad sys_ppoll
486 .quad sys_unshare /* 465 */
487 .quad sys_set_robust_list
488 .quad sys_get_robust_list
489 .quad sys_splice
490 .quad sys_sync_file_range
491 .quad sys_tee /* 470 */
492 .quad sys_vmsplice
493 .quad sys_move_pages
494 .quad sys_getcpu
495 .quad sys_epoll_pwait
496 .quad sys_utimensat /* 475 */
497 .quad sys_signalfd
498 .quad sys_timerfd
499 .quad sys_eventfd
468 500
469 .size sys_call_table, . - sys_call_table 501 .size sys_call_table, . - sys_call_table
470 .type sys_call_table, @object 502 .type sys_call_table, @object
diff --git a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
index ea098f3b629f..266f78e13076 100644
--- a/arch/alpha/lib/Makefile
+++ b/arch/alpha/lib/Makefile
@@ -37,7 +37,8 @@ lib-y = __divqu.o __remqu.o __divlu.o __remlu.o \
37 $(ev6-y)clear_page.o \ 37 $(ev6-y)clear_page.o \
38 $(ev6-y)copy_page.o \ 38 $(ev6-y)copy_page.o \
39 fpreg.o \ 39 fpreg.o \
40 callback_srm.o srm_puts.o srm_printk.o 40 callback_srm.o srm_puts.o srm_printk.o \
41 fls.o
41 42
42lib-$(CONFIG_SMP) += dec_and_lock.o 43lib-$(CONFIG_SMP) += dec_and_lock.o
43 44
diff --git a/arch/alpha/lib/fls.c b/arch/alpha/lib/fls.c
new file mode 100644
index 000000000000..7ad84ea0acf8
--- /dev/null
+++ b/arch/alpha/lib/fls.c
@@ -0,0 +1,38 @@
1/*
2 * arch/alpha/lib/fls.c
3 */
4
5#include <linux/module.h>
6#include <asm/bitops.h>
7
8/* This is fls(x)-1, except zero is held to zero. This allows most
9 efficent input into extbl, plus it allows easy handling of fls(0)=0. */
10
11const unsigned char __flsm1_tab[256] =
12{
13 0,
14 0,
15 1, 1,
16 2, 2, 2, 2,
17 3, 3, 3, 3, 3, 3, 3, 3,
18 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
19
20 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
21 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
22
23 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
24 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
25 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
26 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
27
28 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
29 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
30 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
31 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
32 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
33 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
34 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
35 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
36};
37
38EXPORT_SYMBOL(__flsm1_tab);
diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
index 9179e8220314..f73d62e8ab60 100644
--- a/arch/arm/kernel/armksyms.c
+++ b/arch/arm/kernel/armksyms.c
@@ -57,7 +57,7 @@ extern void fp_enter(void);
57#define EXPORT_SYMBOL_ALIAS(sym,orig) \ 57#define EXPORT_SYMBOL_ALIAS(sym,orig) \
58 EXPORT_CRC_ALIAS(sym) \ 58 EXPORT_CRC_ALIAS(sym) \
59 static const struct kernel_symbol __ksymtab_##sym \ 59 static const struct kernel_symbol __ksymtab_##sym \
60 __attribute_used__ __attribute__((section("__ksymtab"))) = \ 60 __used __attribute__((section("__ksymtab"))) = \
61 { (unsigned long)&orig, #sym }; 61 { (unsigned long)&orig, #sym };
62 62
63/* 63/*
diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 8b63ad89d0a8..ae31deb2d065 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -13,7 +13,7 @@ int walk_stackframe(unsigned long fp, unsigned long low, unsigned long high,
13 /* 13 /*
14 * Check current frame pointer is within bounds 14 * Check current frame pointer is within bounds
15 */ 15 */
16 if ((fp - 12) < low || fp + 4 >= high) 16 if (fp < (low + 12) || fp + 4 >= high)
17 break; 17 break;
18 18
19 frame = (struct stackframe *)(fp - 12); 19 frame = (struct stackframe *)(fp - 12);
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c
index 6043c38c0a9e..af497896a96c 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-dk.c
@@ -132,7 +132,7 @@ static struct mtd_partition __initdata dk_nand_partition[] = {
132 }, 132 },
133}; 133};
134 134
135static struct mtd_partition *nand_partitions(int size, int *num_partitions) 135static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
136{ 136{
137 *num_partitions = ARRAY_SIZE(dk_nand_partition); 137 *num_partitions = ARRAY_SIZE(dk_nand_partition);
138 return dk_nand_partition; 138 return dk_nand_partition;
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index 76f6e1e553ea..7d9b1a278fd6 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -96,7 +96,7 @@ static struct mtd_partition __initdata kb9202_nand_partition[] = {
96 }, 96 },
97}; 97};
98 98
99static struct mtd_partition *nand_partitions(int size, int *num_partitions) 99static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
100{ 100{
101 *num_partitions = ARRAY_SIZE(kb9202_nand_partition); 101 *num_partitions = ARRAY_SIZE(kb9202_nand_partition);
102 return kb9202_nand_partition; 102 return kb9202_nand_partition;
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 1f0c8a400b3a..26ca8ab3f62a 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -178,7 +178,7 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
178 }, 178 },
179}; 179};
180 180
181static struct mtd_partition *nand_partitions(int size, int *num_partitions) 181static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
182{ 182{
183 *num_partitions = ARRAY_SIZE(ek_nand_partition); 183 *num_partitions = ARRAY_SIZE(ek_nand_partition);
184 return ek_nand_partition; 184 return ek_nand_partition;
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index f57458559fb6..c164c8e58ae6 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -180,7 +180,7 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
180 }, 180 },
181}; 181};
182 182
183static struct mtd_partition *nand_partitions(int size, int *num_partitions) 183static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
184{ 184{
185 *num_partitions = ARRAY_SIZE(ek_nand_partition); 185 *num_partitions = ARRAY_SIZE(ek_nand_partition);
186 return ek_nand_partition; 186 return ek_nand_partition;
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index 30c79aca84d4..9b61320f295a 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -87,7 +87,7 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
87 }, 87 },
88}; 88};
89 89
90static struct mtd_partition *nand_partitions(int size, int *num_partitions) 90static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
91{ 91{
92 *num_partitions = ARRAY_SIZE(ek_nand_partition); 92 *num_partitions = ARRAY_SIZE(ek_nand_partition);
93 return ek_nand_partition; 93 return ek_nand_partition;
diff --git a/arch/arm/mach-footbridge/cats-pci.c b/arch/arm/mach-footbridge/cats-pci.c
index 4f984fde7375..35eb232a649a 100644
--- a/arch/arm/mach-footbridge/cats-pci.c
+++ b/arch/arm/mach-footbridge/cats-pci.c
@@ -45,7 +45,7 @@ static struct hw_pci cats_pci __initdata = {
45 .postinit = dc21285_postinit, 45 .postinit = dc21285_postinit,
46}; 46};
47 47
48static int cats_pci_init(void) 48static int __init cats_pci_init(void)
49{ 49{
50 if (machine_is_cats()) 50 if (machine_is_cats())
51 pci_common_init(&cats_pci); 51 pci_common_init(&cats_pci);
diff --git a/arch/arm/mach-imx/generic.c b/arch/arm/mach-imx/generic.c
index 7a7fa51ec62c..1c474cf709ca 100644
--- a/arch/arm/mach-imx/generic.c
+++ b/arch/arm/mach-imx/generic.c
@@ -201,7 +201,6 @@ void __init imx_set_mmc_info(struct imxmmc_platform_data *info)
201{ 201{
202 imx_mmc_device.dev.platform_data = info; 202 imx_mmc_device.dev.platform_data = info;
203} 203}
204EXPORT_SYMBOL(imx_set_mmc_info);
205 204
206static struct imxfb_mach_info imx_fb_info; 205static struct imxfb_mach_info imx_fb_info;
207 206
diff --git a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
index 0fdd03ab36e6..ce7c15c73004 100644
--- a/arch/arm/mach-ixp2000/ixdp2400.c
+++ b/arch/arm/mach-ixp2000/ixdp2400.c
@@ -164,7 +164,7 @@ int __init ixdp2400_pci_init(void)
164 164
165subsys_initcall(ixdp2400_pci_init); 165subsys_initcall(ixdp2400_pci_init);
166 166
167void ixdp2400_init_irq(void) 167void __init ixdp2400_init_irq(void)
168{ 168{
169 ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS); 169 ixdp2x00_init_irq(IXDP2400_CPLD_INT_STAT, IXDP2400_CPLD_INT_MASK, IXDP2400_NR_IRQS);
170} 170}
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index 70d247f09a7e..14f09b80ab77 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -279,7 +279,7 @@ int __init ixdp2800_pci_init(void)
279 279
280subsys_initcall(ixdp2800_pci_init); 280subsys_initcall(ixdp2800_pci_init);
281 281
282void ixdp2800_init_irq(void) 282void __init ixdp2800_init_irq(void)
283{ 283{
284 ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS); 284 ixdp2x00_init_irq(IXDP2800_CPLD_INT_STAT, IXDP2800_CPLD_INT_MASK, IXDP2800_NR_IRQS);
285} 285}
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
index 011065b967b4..73c651e83d92 100644
--- a/arch/arm/mach-ixp2000/ixdp2x00.c
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c
@@ -145,7 +145,7 @@ static struct irq_chip ixdp2x00_cpld_irq_chip = {
145 .unmask = ixdp2x00_irq_unmask 145 .unmask = ixdp2x00_irq_unmask
146}; 146};
147 147
148void ixdp2x00_init_irq(volatile unsigned long *stat_reg, volatile unsigned long *mask_reg, unsigned long nr_irqs) 148void __init ixdp2x00_init_irq(volatile unsigned long *stat_reg, volatile unsigned long *mask_reg, unsigned long nr_irqs)
149{ 149{
150 unsigned int irq; 150 unsigned int irq;
151 151
diff --git a/arch/arm/mach-ixp23xx/ixdp2351.c b/arch/arm/mach-ixp23xx/ixdp2351.c
index 7a86a2516eaa..c41a6b5a0acc 100644
--- a/arch/arm/mach-ixp23xx/ixdp2351.c
+++ b/arch/arm/mach-ixp23xx/ixdp2351.c
@@ -124,7 +124,7 @@ static struct irq_chip ixdp2351_intb_chip = {
124 .unmask = ixdp2351_intb_unmask 124 .unmask = ixdp2351_intb_unmask
125}; 125};
126 126
127void ixdp2351_init_irq(void) 127void __init ixdp2351_init_irq(void)
128{ 128{
129 int irq; 129 int irq;
130 130
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index ac7d43d23c28..227f808dc0ec 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -284,7 +284,7 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
284 return 1; 284 return 1;
285} 285}
286 286
287void ixp23xx_pci_slave_init(void) 287void __init ixp23xx_pci_slave_init(void)
288{ 288{
289 ixp23xx_pci_common_init(); 289 ixp23xx_pci_common_init();
290} 290}
diff --git a/arch/arm/mach-ixp23xx/roadrunner.c b/arch/arm/mach-ixp23xx/roadrunner.c
index d06e21b70de5..e35644961aa4 100644
--- a/arch/arm/mach-ixp23xx/roadrunner.c
+++ b/arch/arm/mach-ixp23xx/roadrunner.c
@@ -110,7 +110,7 @@ static int __init roadrunner_map_irq(struct pci_dev *dev, u8 idsel, u8 pin)
110 return NO_IRQ; 110 return NO_IRQ;
111} 111}
112 112
113static void roadrunner_pci_preinit(void) 113static void __init roadrunner_pci_preinit(void)
114{ 114{
115 set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQT_LOW); 115 set_irq_type(IRQ_ROADRUNNER_PCI_INTC, IRQT_LOW);
116 set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQT_LOW); 116 set_irq_type(IRQ_ROADRUNNER_PCI_INTD, IRQT_LOW);
diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
index 9715ef506c24..060909870b50 100644
--- a/arch/arm/mach-ixp4xx/Kconfig
+++ b/arch/arm/mach-ixp4xx/Kconfig
@@ -104,9 +104,6 @@ config MACH_DSMG600
104 DSM-G600 RevA device. For more information on this platform, 104 DSM-G600 RevA device. For more information on this platform,
105 see http://www.nslu2-linux.org/wiki/DSMG600/HomePage 105 see http://www.nslu2-linux.org/wiki/DSMG600/HomePage
106 106
107#
108# Avila and IXDP share the same source for now. Will change in future
109#
110config ARCH_IXDP4XX 107config ARCH_IXDP4XX
111 bool 108 bool
112 depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435 109 depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 64685da1462d..8112f726ffa0 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -283,7 +283,7 @@ static struct irqaction ixp4xx_timer_irq = {
283 .handler = ixp4xx_timer_interrupt, 283 .handler = ixp4xx_timer_interrupt,
284}; 284};
285 285
286static void __init ixp4xx_timer_init(void) 286void __init ixp4xx_timer_init(void)
287{ 287{
288 /* Reset/disable counter */ 288 /* Reset/disable counter */
289 *IXP4XX_OSRT1 = 0; 289 *IXP4XX_OSRT1 = 0;
diff --git a/arch/arm/mach-ixp4xx/coyote-pci.c b/arch/arm/mach-ixp4xx/coyote-pci.c
index 7bc94f3def1c..ad2e5b97966e 100644
--- a/arch/arm/mach-ixp4xx/coyote-pci.c
+++ b/arch/arm/mach-ixp4xx/coyote-pci.c
@@ -25,10 +25,6 @@
25 25
26#include <asm/mach/pci.h> 26#include <asm/mach/pci.h>
27 27
28extern void ixp4xx_pci_preinit(void);
29extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
30extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
31
32void __init coyote_pci_preinit(void) 28void __init coyote_pci_preinit(void)
33{ 29{
34 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW); 30 set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW);
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
index 1caff65e22cc..1e75e105c4f7 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
@@ -18,6 +18,7 @@
18#include <asm/mach-types.h> 18#include <asm/mach-types.h>
19#include <asm/mach/arch.h> 19#include <asm/mach/arch.h>
20#include <asm/mach/flash.h> 20#include <asm/mach/flash.h>
21#include <asm/mach/time.h>
21 22
22static struct flash_platform_data dsmg600_flash_data = { 23static struct flash_platform_data dsmg600_flash_data = {
23 .map_name = "cfi_probe", 24 .map_name = "cfi_probe",
@@ -128,6 +129,19 @@ static void dsmg600_power_off(void)
128 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); 129 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
129} 130}
130 131
132static void __init dsmg600_timer_init(void)
133{
134 /* The xtal on this machine is non-standard. */
135 ixp4xx_timer_freq = DSMG600_FREQ;
136
137 /* Call standard timer_init function. */
138 ixp4xx_timer_init();
139}
140
141static struct sys_timer dsmg600_timer = {
142 .init = dsmg600_timer_init,
143};
144
131static void __init dsmg600_init(void) 145static void __init dsmg600_init(void)
132{ 146{
133 ixp4xx_sys_init(); 147 ixp4xx_sys_init();
@@ -155,21 +169,13 @@ static void __init dsmg600_init(void)
155#endif 169#endif
156} 170}
157 171
158static void __init dsmg600_fixup(struct machine_desc *desc,
159 struct tag *tags, char **cmdline, struct meminfo *mi)
160{
161 /* The xtal on this machine is non-standard. */
162 ixp4xx_timer_freq = DSMG600_FREQ;
163}
164
165MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") 172MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
166 /* Maintainer: www.nslu2-linux.org */ 173 /* Maintainer: www.nslu2-linux.org */
167 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, 174 .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
168 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, 175 .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
169 .boot_params = 0x00000100, 176 .boot_params = 0x00000100,
170 .fixup = dsmg600_fixup,
171 .map_io = ixp4xx_map_io, 177 .map_io = ixp4xx_map_io,
172 .init_irq = ixp4xx_init_irq, 178 .init_irq = ixp4xx_init_irq,
173 .timer = &ixp4xx_timer, 179 .timer = &dsmg600_timer,
174 .init_machine = dsmg600_init, 180 .init_machine = dsmg600_init,
175MACHINE_END 181MACHINE_END
diff --git a/arch/arm/mach-ixp4xx/ixdpg425-pci.c b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
index 509a95a692a4..d1e75b7dc3b1 100644
--- a/arch/arm/mach-ixp4xx/ixdpg425-pci.c
+++ b/arch/arm/mach-ixp4xx/ixdpg425-pci.c
@@ -23,10 +23,6 @@
23 23
24#include <asm/mach/pci.h> 24#include <asm/mach/pci.h>
25 25
26extern void ixp4xx_pci_preinit(void);
27extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
28extern struct pci_bus *ixp4xx_scan_bus(int nr, struct pci_sys_data *sys);
29
30void __init ixdpg425_pci_preinit(void) 26void __init ixdpg425_pci_preinit(void)
31{ 27{
32 set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW); 28 set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW);
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index 9a31444d9214..78a17413ceca 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -155,7 +155,8 @@ static void __init nas100d_init(void)
155 155
156 pm_power_off = nas100d_power_off; 156 pm_power_off = nas100d_power_off;
157 157
158 /* This is only useful on a modified machine, but it is valuable 158 /*
159 * This is only useful on a modified machine, but it is valuable
159 * to have it first in order to see debug messages, and so that 160 * to have it first in order to see debug messages, and so that
160 * it does *not* get removed if platform_add_devices fails! 161 * it does *not* get removed if platform_add_devices fails!
161 */ 162 */
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index 162c266e5f8f..9bf8ccbcaccf 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -22,6 +22,7 @@
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
24#include <asm/mach/flash.h> 24#include <asm/mach/flash.h>
25#include <asm/mach/time.h>
25 26
26static struct flash_platform_data nslu2_flash_data = { 27static struct flash_platform_data nslu2_flash_data = {
27 .map_name = "cfi_probe", 28 .map_name = "cfi_probe",
@@ -49,26 +50,26 @@ static struct ixp4xx_i2c_pins nslu2_i2c_gpio_pins = {
49static struct resource nslu2_led_resources[] = { 50static struct resource nslu2_led_resources[] = {
50 { 51 {
51 .name = "ready", /* green led */ 52 .name = "ready", /* green led */
52 .start = NSLU2_LED_GRN, 53 .start = NSLU2_LED_GRN_GPIO,
53 .end = NSLU2_LED_GRN, 54 .end = NSLU2_LED_GRN_GPIO,
54 .flags = IXP4XX_GPIO_HIGH, 55 .flags = IXP4XX_GPIO_HIGH,
55 }, 56 },
56 { 57 {
57 .name = "status", /* red led */ 58 .name = "status", /* red led */
58 .start = NSLU2_LED_RED, 59 .start = NSLU2_LED_RED_GPIO,
59 .end = NSLU2_LED_RED, 60 .end = NSLU2_LED_RED_GPIO,
60 .flags = IXP4XX_GPIO_HIGH, 61 .flags = IXP4XX_GPIO_HIGH,
61 }, 62 },
62 { 63 {
63 .name = "disk-1", 64 .name = "disk-1",
64 .start = NSLU2_LED_DISK1, 65 .start = NSLU2_LED_DISK1_GPIO,
65 .end = NSLU2_LED_DISK1, 66 .end = NSLU2_LED_DISK1_GPIO,
66 .flags = IXP4XX_GPIO_LOW, 67 .flags = IXP4XX_GPIO_LOW,
67 }, 68 },
68 { 69 {
69 .name = "disk-2", 70 .name = "disk-2",
70 .start = NSLU2_LED_DISK2, 71 .start = NSLU2_LED_DISK2_GPIO,
71 .end = NSLU2_LED_DISK2, 72 .end = NSLU2_LED_DISK2_GPIO,
72 .flags = IXP4XX_GPIO_LOW, 73 .flags = IXP4XX_GPIO_LOW,
73 }, 74 },
74}; 75};
@@ -157,10 +158,21 @@ static void nslu2_power_off(void)
157 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH); 158 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
158} 159}
159 160
160static void __init nslu2_init(void) 161static void __init nslu2_timer_init(void)
161{ 162{
162 ixp4xx_timer_freq = NSLU2_FREQ; 163 /* The xtal on this machine is non-standard. */
164 ixp4xx_timer_freq = NSLU2_FREQ;
165
166 /* Call standard timer_init function. */
167 ixp4xx_timer_init();
168}
163 169
170static struct sys_timer nslu2_timer = {
171 .init = nslu2_timer_init,
172};
173
174static void __init nslu2_init(void)
175{
164 ixp4xx_sys_init(); 176 ixp4xx_sys_init();
165 177
166 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); 178 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
@@ -169,7 +181,8 @@ static void __init nslu2_init(void)
169 181
170 pm_power_off = nslu2_power_off; 182 pm_power_off = nslu2_power_off;
171 183
172 /* This is only useful on a modified machine, but it is valuable 184 /*
185 * This is only useful on a modified machine, but it is valuable
173 * to have it first in order to see debug messages, and so that 186 * to have it first in order to see debug messages, and so that
174 * it does *not* get removed if platform_add_devices fails! 187 * it does *not* get removed if platform_add_devices fails!
175 */ 188 */
@@ -185,6 +198,6 @@ MACHINE_START(NSLU2, "Linksys NSLU2")
185 .boot_params = 0x00000100, 198 .boot_params = 0x00000100,
186 .map_io = ixp4xx_map_io, 199 .map_io = ixp4xx_map_io,
187 .init_irq = ixp4xx_init_irq, 200 .init_irq = ixp4xx_init_irq,
188 .timer = &ixp4xx_timer, 201 .timer = &nslu2_timer,
189 .init_machine = nslu2_init, 202 .init_machine = nslu2_init,
190MACHINE_END 203MACHINE_END
diff --git a/arch/arm/mach-s3c2410/bast.h b/arch/arm/mach-s3c2410/bast.h
deleted file mode 100644
index e98543742eb9..000000000000
--- a/arch/arm/mach-s3c2410/bast.h
+++ /dev/null
@@ -1,2 +0,0 @@
1/* linux/arch/arm/mach-s3c2410/bast.h
2extern void bast_init_irq(void);
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c2410/mach-amlm5900.c
index bc308ceb91c3..435adcce6482 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c2410/mach-amlm5900.c
@@ -160,7 +160,7 @@ static struct platform_device *amlm5900_devices[] __initdata = {
160#endif 160#endif
161}; 161};
162 162
163void __init amlm5900_map_io(void) 163static void __init amlm5900_map_io(void)
164{ 164{
165 s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc)); 165 s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc));
166 s3c24xx_init_clocks(0); 166 s3c24xx_init_clocks(0);
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index c602aa39f9c4..782b5814ced2 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -16,6 +16,7 @@
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/timer.h> 17#include <linux/timer.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/delay.h>
19#include <linux/sysdev.h> 20#include <linux/sysdev.h>
20#include <linux/serial_core.h> 21#include <linux/serial_core.h>
21#include <linux/platform_device.h> 22#include <linux/platform_device.h>
@@ -29,6 +30,7 @@
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31 32
33#include <asm/arch/reset.h>
32#include <asm/arch/idle.h> 34#include <asm/arch/idle.h>
33 35
34#include <asm/arch/regs-clock.h> 36#include <asm/arch/regs-clock.h>
@@ -38,6 +40,7 @@
38#include <asm/arch/regs-gpioj.h> 40#include <asm/arch/regs-gpioj.h>
39#include <asm/arch/regs-dsc.h> 41#include <asm/arch/regs-dsc.h>
40#include <asm/arch/regs-spi.h> 42#include <asm/arch/regs-spi.h>
43#include <asm/arch/regs-s3c2412.h>
41 44
42#include <asm/plat-s3c24xx/s3c2412.h> 45#include <asm/plat-s3c24xx/s3c2412.h>
43#include <asm/plat-s3c24xx/cpu.h> 46#include <asm/plat-s3c24xx/cpu.h>
@@ -106,6 +109,23 @@ static void s3c2412_idle(void)
106 cpu_do_idle(); 109 cpu_do_idle();
107} 110}
108 111
112static void s3c2412_hard_reset(void)
113{
114 /* errata "Watch-dog/Software Reset Problem" specifies that
115 * this reset must be done with the SYSCLK sourced from
116 * EXTCLK instead of FOUT to avoid a glitch in the reset
117 * mechanism.
118 *
119 * See the watchdog section of the S3C2412 manual for more
120 * information on this fix.
121 */
122
123 __raw_writel(0x00, S3C2412_CLKSRC);
124 __raw_writel(S3C2412_SWRST_RESET, S3C2412_SWRST);
125
126 mdelay(1);
127}
128
109/* s3c2412_map_io 129/* s3c2412_map_io
110 * 130 *
111 * register the standard cpu IO areas, and any passed in from the 131 * register the standard cpu IO areas, and any passed in from the
@@ -122,6 +142,10 @@ void __init s3c2412_map_io(struct map_desc *mach_desc, int mach_size)
122 142
123 s3c24xx_idle = s3c2412_idle; 143 s3c24xx_idle = s3c2412_idle;
124 144
145 /* set custom reset hook */
146
147 s3c24xx_reset_hook = s3c2412_hard_reset;
148
125 /* register our io-tables */ 149 /* register our io-tables */
126 150
127 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc)); 151 iotable_init(s3c2412_iodesc, ARRAY_SIZE(s3c2412_iodesc));
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c2443/clock.c
index 5955efb5de8d..58402948c47c 100644
--- a/arch/arm/mach-s3c2443/clock.c
+++ b/arch/arm/mach-s3c2443/clock.c
@@ -394,7 +394,7 @@ static int s3c2443_setrate_usbhost(struct clk *clk, unsigned long rate)
394 return 0; 394 return 0;
395} 395}
396 396
397struct clk clk_usb_bus_host = { 397static struct clk clk_usb_bus_host = {
398 .name = "usb-bus-host-parent", 398 .name = "usb-bus-host-parent",
399 .id = -1, 399 .id = -1,
400 .parent = &clk_esysclk, 400 .parent = &clk_esysclk,
@@ -758,7 +758,6 @@ static struct clk init_clocks[] = {
758 .parent = &clk_h, 758 .parent = &clk_h,
759 .enable = s3c2443_clkcon_enable_h, 759 .enable = s3c2443_clkcon_enable_h,
760 .ctrlbit = S3C2443_HCLKCON_CFC, 760 .ctrlbit = S3C2443_HCLKCON_CFC,
761 .ctrlbit = S3C2443_HCLKCON_HSMMC,
762 }, { 761 }, {
763 .name = "ssmc", 762 .name = "ssmc",
764 .id = -1, 763 .id = -1,
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index d7c038a0256b..4cbf9468f654 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -139,12 +139,12 @@ static u_int neponset_get_mctrl(struct uart_port *port)
139 return ret; 139 return ret;
140} 140}
141 141
142static struct sa1100_port_fns neponset_port_fns __initdata = { 142static struct sa1100_port_fns neponset_port_fns __devinitdata = {
143 .set_mctrl = neponset_set_mctrl, 143 .set_mctrl = neponset_set_mctrl,
144 .get_mctrl = neponset_get_mctrl, 144 .get_mctrl = neponset_get_mctrl,
145}; 145};
146 146
147static int neponset_probe(struct platform_device *dev) 147static int __devinit neponset_probe(struct platform_device *dev)
148{ 148{
149 sa1100_register_uart_fns(&neponset_port_fns); 149 sa1100_register_uart_fns(&neponset_port_fns);
150 150
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 5f472a8b406a..e7904bc92c73 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -379,7 +379,7 @@ config CPU_V7
379 select CPU_CP15_MMU 379 select CPU_CP15_MMU
380 select CPU_HAS_ASID 380 select CPU_HAS_ASID
381 select CPU_COPY_V6 if MMU 381 select CPU_COPY_V6 if MMU
382 select CPU_TLB_V6 if MMU 382 select CPU_TLB_V7 if MMU
383 383
384# Figure out what processor architecture version we should be using. 384# Figure out what processor architecture version we should be using.
385# This defines the compiler instruction set which depends on the machine type. 385# This defines the compiler instruction set which depends on the machine type.
@@ -498,6 +498,9 @@ config CPU_TLB_V4WBI
498config CPU_TLB_V6 498config CPU_TLB_V6
499 bool 499 bool
500 500
501config CPU_TLB_V7
502 bool
503
501endif 504endif
502 505
503config CPU_HAS_ASID 506config CPU_HAS_ASID
diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile
index b5bd335ff14a..762702765fc3 100644
--- a/arch/arm/mm/Makefile
+++ b/arch/arm/mm/Makefile
@@ -46,6 +46,7 @@ obj-$(CONFIG_CPU_TLB_V4WT) += tlb-v4.o
46obj-$(CONFIG_CPU_TLB_V4WB) += tlb-v4wb.o 46obj-$(CONFIG_CPU_TLB_V4WB) += tlb-v4wb.o
47obj-$(CONFIG_CPU_TLB_V4WBI) += tlb-v4wbi.o 47obj-$(CONFIG_CPU_TLB_V4WBI) += tlb-v4wbi.o
48obj-$(CONFIG_CPU_TLB_V6) += tlb-v6.o 48obj-$(CONFIG_CPU_TLB_V6) += tlb-v6.o
49obj-$(CONFIG_CPU_TLB_V7) += tlb-v7.o
49 50
50obj-$(CONFIG_CPU_ARM610) += proc-arm6_7.o 51obj-$(CONFIG_CPU_ARM610) += proc-arm6_7.o
51obj-$(CONFIG_CPU_ARM710) += proc-arm6_7.o 52obj-$(CONFIG_CPU_ARM710) += proc-arm6_7.o
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index 36440c899583..074b7cb07743 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -630,7 +630,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
630 630
631 fs = get_fs(); 631 fs = get_fs();
632 set_fs(KERNEL_DS); 632 set_fs(KERNEL_DS);
633 if thumb_mode(regs) { 633 if (thumb_mode(regs)) {
634 fault = __get_user(tinstr, (u16 *)(instrptr & ~1)); 634 fault = __get_user(tinstr, (u16 *)(instrptr & ~1));
635 if (!(fault)) 635 if (!(fault))
636 instr = thumb2arm(tinstr); 636 instr = thumb2arm(tinstr);
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index dd823dd4a374..718f4782ee8b 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -256,7 +256,7 @@ __v7_proc_info:
256 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP 256 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
257 .long cpu_v7_name 257 .long cpu_v7_name
258 .long v7_processor_functions 258 .long v7_processor_functions
259 .long v6wbi_tlb_fns 259 .long v7wbi_tlb_fns
260 .long v6_user_fns 260 .long v6_user_fns
261 .long v7_cache_fns 261 .long v7_cache_fns
262 .size __v7_proc_info, . - __v7_proc_info 262 .size __v7_proc_info, . - __v7_proc_info
diff --git a/arch/arm/mm/tlb-v7.S b/arch/arm/mm/tlb-v7.S
new file mode 100644
index 000000000000..b56dda8052f7
--- /dev/null
+++ b/arch/arm/mm/tlb-v7.S
@@ -0,0 +1,88 @@
1/*
2 * linux/arch/arm/mm/tlb-v7.S
3 *
4 * Copyright (C) 1997-2002 Russell King
5 * Modified for ARMv7 by Catalin Marinas
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * ARM architecture version 6 TLB handling functions.
12 * These assume a split I/D TLB.
13 */
14#include <linux/linkage.h>
15#include <asm/asm-offsets.h>
16#include <asm/page.h>
17#include <asm/tlbflush.h>
18#include "proc-macros.S"
19
20/*
21 * v7wbi_flush_user_tlb_range(start, end, vma)
22 *
23 * Invalidate a range of TLB entries in the specified address space.
24 *
25 * - start - start address (may not be aligned)
26 * - end - end address (exclusive, may not be aligned)
27 * - vma - vma_struct describing address range
28 *
29 * It is assumed that:
30 * - the "Invalidate single entry" instruction will invalidate
31 * both the I and the D TLBs on Harvard-style TLBs
32 */
33ENTRY(v7wbi_flush_user_tlb_range)
34 vma_vm_mm r3, r2 @ get vma->vm_mm
35 mmid r3, r3 @ get vm_mm->context.id
36 dsb
37 mov r0, r0, lsr #PAGE_SHIFT @ align address
38 mov r1, r1, lsr #PAGE_SHIFT
39 asid r3, r3 @ mask ASID
40 orr r0, r3, r0, lsl #PAGE_SHIFT @ Create initial MVA
41 mov r1, r1, lsl #PAGE_SHIFT
42 vma_vm_flags r2, r2 @ get vma->vm_flags
431:
44 mcr p15, 0, r0, c8, c6, 1 @ TLB invalidate D MVA (was 1)
45 tst r2, #VM_EXEC @ Executable area ?
46 mcrne p15, 0, r0, c8, c5, 1 @ TLB invalidate I MVA (was 1)
47 add r0, r0, #PAGE_SZ
48 cmp r0, r1
49 blo 1b
50 mov ip, #0
51 mcr p15, 0, ip, c7, c5, 6 @ flush BTAC/BTB
52 dsb
53 mov pc, lr
54
55/*
56 * v7wbi_flush_kern_tlb_range(start,end)
57 *
58 * Invalidate a range of kernel TLB entries
59 *
60 * - start - start address (may not be aligned)
61 * - end - end address (exclusive, may not be aligned)
62 */
63ENTRY(v7wbi_flush_kern_tlb_range)
64 dsb
65 mov r0, r0, lsr #PAGE_SHIFT @ align address
66 mov r1, r1, lsr #PAGE_SHIFT
67 mov r0, r0, lsl #PAGE_SHIFT
68 mov r1, r1, lsl #PAGE_SHIFT
691:
70 mcr p15, 0, r0, c8, c6, 1 @ TLB invalidate D MVA
71 mcr p15, 0, r0, c8, c5, 1 @ TLB invalidate I MVA
72 add r0, r0, #PAGE_SZ
73 cmp r0, r1
74 blo 1b
75 mov r2, #0
76 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
77 dsb
78 isb
79 mov pc, lr
80
81 .section ".text.init", #alloc, #execinstr
82
83 .type v7wbi_tlb_fns, #object
84ENTRY(v7wbi_tlb_fns)
85 .long v7wbi_flush_user_tlb_range
86 .long v7wbi_flush_kern_tlb_range
87 .long v6wbi_tlb_flags
88 .size v7wbi_tlb_fns, . - v7wbi_tlb_fns
diff --git a/arch/arm/nwfpe/softfloat.h b/arch/arm/nwfpe/softfloat.h
index 0a3067452cd2..260fe29d73f5 100644
--- a/arch/arm/nwfpe/softfloat.h
+++ b/arch/arm/nwfpe/softfloat.h
@@ -273,4 +273,7 @@ static inline flag float64_lt_nocheck(float64 a, float64 b)
273extern flag float32_is_nan( float32 a ); 273extern flag float32_is_nan( float32 a );
274extern flag float64_is_nan( float64 a ); 274extern flag float64_is_nan( float64 a );
275 275
276extern int32 float64_to_uint32( struct roundingData *roundData, float64 a );
277extern int32 float64_to_uint32_round_to_zero( float64 a );
278
276#endif 279#endif
diff --git a/arch/arm/oprofile/op_model_mpcore.c b/arch/arm/oprofile/op_model_mpcore.c
index 898500718249..7791da791f5f 100644
--- a/arch/arm/oprofile/op_model_mpcore.c
+++ b/arch/arm/oprofile/op_model_mpcore.c
@@ -257,8 +257,13 @@ static void em_stop(void)
257 */ 257 */
258static void em_route_irq(int irq, unsigned int cpu) 258static void em_route_irq(int irq, unsigned int cpu)
259{ 259{
260 irq_desc[irq].affinity = cpumask_of_cpu(cpu); 260 struct irq_desc *desc = irq_desc + irq;
261 irq_desc[irq].chip->set_affinity(irq, cpumask_of_cpu(cpu)); 261 cpumask_t mask = cpumask_of_cpu(cpu);
262
263 spin_lock_irq(&desc->lock);
264 desc->affinity = mask;
265 desc->chip->set_affinity(irq, mask);
266 spin_unlock_irq(&desc->lock);
262} 267}
263 268
264static int em_setup(void) 269static int em_setup(void)
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c
index 11ba75a05220..de7688cfd573 100644
--- a/arch/h8300/kernel/sys_h8300.c
+++ b/arch/h8300/kernel/sys_h8300.c
@@ -288,9 +288,9 @@ asmlinkage void syscall_print(void *dummy,...)
288int kernel_execve(const char *filename, char *const argv[], char *const envp[]) 288int kernel_execve(const char *filename, char *const argv[], char *const envp[])
289{ 289{
290 register long res __asm__("er0"); 290 register long res __asm__("er0");
291 register char *const *_c __asm__("er3") = envp;
292 register char *const *_b __asm__("er2") = argv;
291 register const char * _a __asm__("er1") = filename; 293 register const char * _a __asm__("er1") = filename;
292 register void *_b __asm__("er2") = argv;
293 register void *_c __asm__("er3") = envp;
294 __asm__ __volatile__ ("mov.l %1,er0\n\t" 294 __asm__ __volatile__ ("mov.l %1,er0\n\t"
295 "trapa #0\n\t" 295 "trapa #0\n\t"
296 : "=r" (res) 296 : "=r" (res)
diff --git a/arch/h8300/kernel/traps.c b/arch/h8300/kernel/traps.c
index 300e3279ca5a..f97183011c2c 100644
--- a/arch/h8300/kernel/traps.c
+++ b/arch/h8300/kernel/traps.c
@@ -136,7 +136,7 @@ void show_stack(struct task_struct *task, unsigned long *esp)
136 printk("\nCall Trace:"); 136 printk("\nCall Trace:");
137 i = 0; 137 i = 0;
138 stack = esp; 138 stack = esp;
139 while (((unsigned long)stack & (THREAD_SIZE - 1)) == 0) { 139 while (((unsigned long)stack & (THREAD_SIZE - 1)) != 0) {
140 addr = *stack++; 140 addr = *stack++;
141 /* 141 /*
142 * If the address is either in the text segment of the 142 * If the address is either in the text segment of the
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 83f825f2e2d7..d865d041bea1 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -478,7 +478,7 @@ static int __init microcode_dev_init (void)
478 return 0; 478 return 0;
479} 479}
480 480
481static void __exit microcode_dev_exit (void) 481static void microcode_dev_exit (void)
482{ 482{
483 misc_deregister(&microcode_dev); 483 misc_deregister(&microcode_dev);
484} 484}
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 50dfc65319cd..5513f8d5b5be 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -89,6 +89,14 @@ static int __init set_bios_reboot(struct dmi_system_id *d)
89} 89}
90 90
91static struct dmi_system_id __initdata reboot_dmi_table[] = { 91static struct dmi_system_id __initdata reboot_dmi_table[] = {
92 { /* Handle problems with rebooting on Dell E520's */
93 .callback = set_bios_reboot,
94 .ident = "Dell E520",
95 .matches = {
96 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
97 DMI_MATCH(DMI_PRODUCT_NAME, "Dell DM061"),
98 },
99 },
92 { /* Handle problems with rebooting on Dell 1300's */ 100 { /* Handle problems with rebooting on Dell 1300's */
93 .callback = set_bios_reboot, 101 .callback = set_bios_reboot,
94 .ident = "Dell PowerEdge 1300", 102 .ident = "Dell PowerEdge 1300",
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 08f07a74a9d3..88baed1e7e83 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -943,10 +943,9 @@ exit:
943 943
944static void smp_tune_scheduling(void) 944static void smp_tune_scheduling(void)
945{ 945{
946 unsigned long cachesize; /* kB */
947
948 if (cpu_khz) { 946 if (cpu_khz) {
949 cachesize = boot_cpu_data.x86_cache_size; 947 /* cache size in kB */
948 long cachesize = boot_cpu_data.x86_cache_size;
950 949
951 if (cachesize > 0) 950 if (cachesize > 0)
952 max_cache_size = cachesize * 1024; 951 max_cache_size = cachesize * 1024;
diff --git a/arch/i386/kernel/vmi.c b/arch/i386/kernel/vmi.c
index c8726c424b35..c12720d7cbc5 100644
--- a/arch/i386/kernel/vmi.c
+++ b/arch/i386/kernel/vmi.c
@@ -27,6 +27,7 @@
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/highmem.h> 29#include <linux/highmem.h>
30#include <linux/sched.h>
30#include <asm/vmi.h> 31#include <asm/vmi.h>
31#include <asm/io.h> 32#include <asm/io.h>
32#include <asm/fixmap.h> 33#include <asm/fixmap.h>
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index a7c0783b269a..11b7a51566a8 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -154,7 +154,7 @@ static int allocate_msrs(void)
154 size_t counters_size = sizeof(struct op_msr) * model->num_counters; 154 size_t counters_size = sizeof(struct op_msr) * model->num_counters;
155 155
156 int i; 156 int i;
157 for_each_online_cpu(i) { 157 for_each_possible_cpu(i) {
158 cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL); 158 cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL);
159 if (!cpu_msrs[i].counters) { 159 if (!cpu_msrs[i].counters) {
160 success = 0; 160 success = 0;
@@ -211,8 +211,14 @@ static int nmi_setup(void)
211 /* Assume saved/restored counters are the same on all CPUs */ 211 /* Assume saved/restored counters are the same on all CPUs */
212 model->fill_in_addresses(&cpu_msrs[0]); 212 model->fill_in_addresses(&cpu_msrs[0]);
213 for_each_possible_cpu (cpu) { 213 for_each_possible_cpu (cpu) {
214 if (cpu != 0) 214 if (cpu != 0) {
215 cpu_msrs[cpu] = cpu_msrs[0]; 215 memcpy(cpu_msrs[cpu].counters, cpu_msrs[0].counters,
216 sizeof(struct op_msr) * model->num_counters);
217
218 memcpy(cpu_msrs[cpu].controls, cpu_msrs[0].controls,
219 sizeof(struct op_msr) * model->num_controls);
220 }
221
216 } 222 }
217 on_each_cpu(nmi_save_registers, NULL, 0, 1); 223 on_each_cpu(nmi_save_registers, NULL, 0, 1);
218 on_each_cpu(nmi_cpu_setup, NULL, 0, 1); 224 on_each_cpu(nmi_cpu_setup, NULL, 0, 1);
diff --git a/arch/i386/pci/fixup.c b/arch/i386/pci/fixup.c
index b62eafb997bc..b95b42950ed4 100644
--- a/arch/i386/pci/fixup.c
+++ b/arch/i386/pci/fixup.c
@@ -436,3 +436,14 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY,
436 pci_early_fixup_cyrix_5530); 436 pci_early_fixup_cyrix_5530);
437DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, 437DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY,
438 pci_early_fixup_cyrix_5530); 438 pci_early_fixup_cyrix_5530);
439
440/*
441 * Siemens Nixdorf AG FSC Multiprocessor Interrupt Controller:
442 * prevent update of the BAR0, which doesn't look like a normal BAR.
443 */
444static void __devinit pci_siemens_interrupt_controller(struct pci_dev *dev)
445{
446 dev->resource[0].flags |= IORESOURCE_PCI_FIXED;
447}
448DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SIEMENS, 0x0015,
449 pci_siemens_interrupt_controller);
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index b8536c7c0877..85cdd23b0447 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -355,8 +355,9 @@ config RMW_INSNS
355 adventurous. 355 adventurous.
356 356
357config SINGLE_MEMORY_CHUNK 357config SINGLE_MEMORY_CHUNK
358 bool "Use one physical chunk of memory only" 358 bool "Use one physical chunk of memory only" if ADVANCED && !SUN3
359 depends on ADVANCED && !SUN3 359 default y if SUN3
360 select NEED_MULTIPLE_NODES
360 help 361 help
361 Ignore all but the first contiguous chunk of physical memory for VM 362 Ignore all but the first contiguous chunk of physical memory for VM
362 purposes. This will save a few bytes kernel size and may speed up 363 purposes. This will save a few bytes kernel size and may speed up
@@ -377,6 +378,14 @@ config 060_WRITETHROUGH
377 is hardwired on. The 53c710 SCSI driver is known to suffer from 378 is hardwired on. The 53c710 SCSI driver is known to suffer from
378 this problem. 379 this problem.
379 380
381config ARCH_DISCONTIGMEM_ENABLE
382 def_bool !SINGLE_MEMORY_CHUNK
383
384config NODES_SHIFT
385 int
386 default "3"
387 depends on !SINGLE_MEMORY_CHUNK
388
380source "mm/Kconfig" 389source "mm/Kconfig"
381 390
382endmenu 391endmenu
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index c20831a7e1a9..aa383a5ea7ac 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -19,6 +19,7 @@ COMPILE_ARCH = $(shell uname -m)
19# override top level makefile 19# override top level makefile
20AS += -m68020 20AS += -m68020
21LDFLAGS := -m m68kelf 21LDFLAGS := -m m68kelf
22LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
22ifneq ($(COMPILE_ARCH),$(ARCH)) 23ifneq ($(COMPILE_ARCH),$(ARCH))
23 # prefix for cross-compiling binaries 24 # prefix for cross-compiling binaries
24 CROSS_COMPILE = m68k-linux-gnu- 25 CROSS_COMPILE = m68k-linux-gnu-
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index 0b68ab8d63d1..a806208c7fb5 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -9,13 +9,12 @@ else
9endif 9endif
10extra-y += vmlinux.lds 10extra-y += vmlinux.lds
11 11
12obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o \ 12obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o module.o \
13 sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o devres.o 13 sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o devres.o
14 14
15devres-y = ../../../kernel/irq/devres.o 15devres-y = ../../../kernel/irq/devres.o
16 16
17obj-$(CONFIG_PCI) += bios32.o 17obj-$(CONFIG_PCI) += bios32.o
18obj-$(CONFIG_MODULES) += module.o
19obj-y$(CONFIG_MMU_SUN3) += dma.o # no, it's not a typo 18obj-y$(CONFIG_MMU_SUN3) += dma.o # no, it's not a typo
20 19
21EXTRA_AFLAGS := -traditional 20EXTRA_AFLAGS := -traditional
diff --git a/arch/m68k/kernel/module.c b/arch/m68k/kernel/module.c
index 3b1a2ff61ddc..774862bc6977 100644
--- a/arch/m68k/kernel/module.c
+++ b/arch/m68k/kernel/module.c
@@ -1,3 +1,9 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file COPYING in the main directory of this archive
4 * for more details.
5 */
6
1#include <linux/moduleloader.h> 7#include <linux/moduleloader.h>
2#include <linux/elf.h> 8#include <linux/elf.h>
3#include <linux/vmalloc.h> 9#include <linux/vmalloc.h>
@@ -11,6 +17,8 @@
11#define DEBUGP(fmt...) 17#define DEBUGP(fmt...)
12#endif 18#endif
13 19
20#ifdef CONFIG_MODULES
21
14void *module_alloc(unsigned long size) 22void *module_alloc(unsigned long size)
15{ 23{
16 if (size == 0) 24 if (size == 0)
@@ -118,11 +126,32 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
118 126
119int module_finalize(const Elf_Ehdr *hdr, 127int module_finalize(const Elf_Ehdr *hdr,
120 const Elf_Shdr *sechdrs, 128 const Elf_Shdr *sechdrs,
121 struct module *me) 129 struct module *mod)
122{ 130{
131 module_fixup(mod, mod->arch.fixup_start, mod->arch.fixup_end);
132
123 return 0; 133 return 0;
124} 134}
125 135
126void module_arch_cleanup(struct module *mod) 136void module_arch_cleanup(struct module *mod)
127{ 137{
128} 138}
139
140#endif /* CONFIG_MODULES */
141
142void module_fixup(struct module *mod, struct m68k_fixup_info *start,
143 struct m68k_fixup_info *end)
144{
145 struct m68k_fixup_info *fixup;
146
147 for (fixup = start; fixup < end; fixup++) {
148 switch (fixup->type) {
149 case m68k_fixup_memoffset:
150 *(u32 *)fixup->addr = m68k_memoffset;
151 break;
152 case m68k_fixup_vnode_shift:
153 *(u16 *)fixup->addr += m68k_virt_to_node_shift;
154 break;
155 }
156 }
157}
diff --git a/arch/m68k/kernel/module.lds b/arch/m68k/kernel/module.lds
new file mode 100644
index 000000000000..fda94fa38243
--- /dev/null
+++ b/arch/m68k/kernel/module.lds
@@ -0,0 +1,7 @@
1SECTIONS {
2 .m68k_fixup : {
3 __start_fixup = .;
4 *(.m68k_fixup)
5 __stop_fixup = .;
6 }
7}
diff --git a/arch/m68k/kernel/setup.c b/arch/m68k/kernel/setup.c
index 610319356691..215c7bd43924 100644
--- a/arch/m68k/kernel/setup.c
+++ b/arch/m68k/kernel/setup.c
@@ -60,14 +60,12 @@ extern unsigned long availmem;
60int m68k_num_memory; 60int m68k_num_memory;
61int m68k_realnum_memory; 61int m68k_realnum_memory;
62EXPORT_SYMBOL(m68k_realnum_memory); 62EXPORT_SYMBOL(m68k_realnum_memory);
63#ifdef CONFIG_SINGLE_MEMORY_CHUNK
64unsigned long m68k_memoffset; 63unsigned long m68k_memoffset;
65EXPORT_SYMBOL(m68k_memoffset); 64EXPORT_SYMBOL(m68k_memoffset);
66#endif
67struct mem_info m68k_memory[NUM_MEMINFO]; 65struct mem_info m68k_memory[NUM_MEMINFO];
68EXPORT_SYMBOL(m68k_memory); 66EXPORT_SYMBOL(m68k_memory);
69 67
70static struct mem_info m68k_ramdisk; 68struct mem_info m68k_ramdisk;
71 69
72static char m68k_command_line[CL_SIZE]; 70static char m68k_command_line[CL_SIZE];
73 71
@@ -208,9 +206,6 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
208void __init setup_arch(char **cmdline_p) 206void __init setup_arch(char **cmdline_p)
209{ 207{
210 extern int _etext, _edata, _end; 208 extern int _etext, _edata, _end;
211#ifndef CONFIG_SUN3
212 unsigned long endmem, startmem;
213#endif
214 int i; 209 int i;
215 210
216 /* The bootinfo is located right after the kernel bss */ 211 /* The bootinfo is located right after the kernel bss */
@@ -320,30 +315,16 @@ void __init setup_arch(char **cmdline_p)
320 panic("No configuration setup"); 315 panic("No configuration setup");
321 } 316 }
322 317
323#ifndef CONFIG_SUN3 318 paging_init();
324 startmem= m68k_memory[0].addr;
325 endmem = startmem + m68k_memory[0].size;
326 high_memory = (void *)PAGE_OFFSET;
327 for (i = 0; i < m68k_num_memory; i++) {
328 m68k_memory[i].size &= MASK_256K;
329 if (m68k_memory[i].addr < startmem)
330 startmem = m68k_memory[i].addr;
331 if (m68k_memory[i].addr+m68k_memory[i].size > endmem)
332 endmem = m68k_memory[i].addr+m68k_memory[i].size;
333 high_memory += m68k_memory[i].size;
334 }
335
336 availmem += init_bootmem_node(NODE_DATA(0), availmem >> PAGE_SHIFT,
337 startmem >> PAGE_SHIFT, endmem >> PAGE_SHIFT);
338
339 for (i = 0; i < m68k_num_memory; i++)
340 free_bootmem(m68k_memory[i].addr, m68k_memory[i].size);
341
342 reserve_bootmem(m68k_memory[0].addr, availmem - m68k_memory[0].addr);
343 319
320#ifndef CONFIG_SUN3
321 for (i = 1; i < m68k_num_memory; i++)
322 free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
323 m68k_memory[i].size);
344#ifdef CONFIG_BLK_DEV_INITRD 324#ifdef CONFIG_BLK_DEV_INITRD
345 if (m68k_ramdisk.size) { 325 if (m68k_ramdisk.size) {
346 reserve_bootmem(m68k_ramdisk.addr, m68k_ramdisk.size); 326 reserve_bootmem_node(__virt_to_node(phys_to_virt(m68k_ramdisk.addr)),
327 m68k_ramdisk.addr, m68k_ramdisk.size);
347 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr); 328 initrd_start = (unsigned long)phys_to_virt(m68k_ramdisk.addr);
348 initrd_end = initrd_start + m68k_ramdisk.size; 329 initrd_end = initrd_start + m68k_ramdisk.size;
349 printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end); 330 printk("initrd: %08lx - %08lx\n", initrd_start, initrd_end);
@@ -362,8 +343,6 @@ void __init setup_arch(char **cmdline_p)
362 343
363#endif /* !CONFIG_SUN3 */ 344#endif /* !CONFIG_SUN3 */
364 345
365 paging_init();
366
367/* set ISA defs early as possible */ 346/* set ISA defs early as possible */
368#if defined(CONFIG_ISA) && defined(MULTI_ISA) 347#if defined(CONFIG_ISA) && defined(MULTI_ISA)
369#if defined(CONFIG_Q40) 348#if defined(CONFIG_Q40)
diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds
index 78f139226a1b..40f02b128f22 100644
--- a/arch/m68k/kernel/vmlinux-std.lds
+++ b/arch/m68k/kernel/vmlinux-std.lds
@@ -60,6 +60,11 @@ SECTIONS
60 __con_initcall_start = .; 60 __con_initcall_start = .;
61 .con_initcall.init : { *(.con_initcall.init) } 61 .con_initcall.init : { *(.con_initcall.init) }
62 __con_initcall_end = .; 62 __con_initcall_end = .;
63 .m68k_fixup : {
64 __start_fixup = .;
65 *(.m68k_fixup)
66 __stop_fixup = .;
67 }
63 SECURITY_INIT 68 SECURITY_INIT
64#ifdef CONFIG_BLK_DEV_INITRD 69#ifdef CONFIG_BLK_DEV_INITRD
65 . = ALIGN(8192); 70 . = ALIGN(8192);
diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds
index c8999b2db23b..f06425b6d206 100644
--- a/arch/m68k/kernel/vmlinux-sun3.lds
+++ b/arch/m68k/kernel/vmlinux-sun3.lds
@@ -54,6 +54,11 @@ __init_begin = .;
54 __con_initcall_start = .; 54 __con_initcall_start = .;
55 .con_initcall.init : { *(.con_initcall.init) } 55 .con_initcall.init : { *(.con_initcall.init) }
56 __con_initcall_end = .; 56 __con_initcall_end = .;
57 .m68k_fixup : {
58 __start_fixup = .;
59 *(.m68k_fixup)
60 __stop_fixup = .;
61 }
57 SECURITY_INIT 62 SECURITY_INIT
58#ifdef CONFIG_BLK_DEV_INITRD 63#ifdef CONFIG_BLK_DEV_INITRD
59 . = ALIGN(8192); 64 . = ALIGN(8192);
diff --git a/arch/m68k/mac/debug.c b/arch/m68k/mac/debug.c
index 7a5bed5bdc57..e8a57138b4a6 100644
--- a/arch/m68k/mac/debug.c
+++ b/arch/m68k/mac/debug.c
@@ -71,7 +71,7 @@ void mac_debugging_short(int pos, short num)
71 71
72 /* calculate current offset */ 72 /* calculate current offset */
73 pengoffset = (unsigned char *)mac_videobase + 73 pengoffset = (unsigned char *)mac_videobase +
74 (150+line*2) * mac_rowbytes) + 80 * peng; 74 (150+line*2) * mac_rowbytes + 80 * peng;
75 75
76 pptr = pengoffset; 76 pptr = pengoffset;
77 77
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index ab90213e5c54..f1de19e1dde6 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -7,6 +7,7 @@
7 * to motorola.c and sun3mmu.c 7 * to motorola.c and sun3mmu.c
8 */ 8 */
9 9
10#include <linux/module.h>
10#include <linux/signal.h> 11#include <linux/signal.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/mm.h> 13#include <linux/mm.h>
@@ -31,6 +32,37 @@
31 32
32DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 33DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
33 34
35static bootmem_data_t __initdata bootmem_data[MAX_NUMNODES];
36
37pg_data_t pg_data_map[MAX_NUMNODES];
38EXPORT_SYMBOL(pg_data_map);
39
40int m68k_virt_to_node_shift;
41
42#ifndef CONFIG_SINGLE_MEMORY_CHUNK
43pg_data_t *pg_data_table[65];
44EXPORT_SYMBOL(pg_data_table);
45#endif
46
47void m68k_setup_node(int node)
48{
49#ifndef CONFIG_SINGLE_MEMORY_CHUNK
50 struct mem_info *info = m68k_memory + node;
51 int i, end;
52
53 i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
54 end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
55 for (; i <= end; i++) {
56 if (pg_data_table[i])
57 printk("overlap at %u for chunk %u\n", i, node);
58 pg_data_table[i] = pg_data_map + node;
59 }
60#endif
61 pg_data_map[node].bdata = bootmem_data + node;
62 node_set_online(node);
63}
64
65
34/* 66/*
35 * ZERO_PAGE is a special page that is used for zero-initialized 67 * ZERO_PAGE is a special page that is used for zero-initialized
36 * data and COW. 68 * data and COW.
@@ -40,52 +72,51 @@ void *empty_zero_page;
40 72
41void show_mem(void) 73void show_mem(void)
42{ 74{
43 unsigned long i; 75 pg_data_t *pgdat;
44 int free = 0, total = 0, reserved = 0, shared = 0; 76 int free = 0, total = 0, reserved = 0, shared = 0;
45 int cached = 0; 77 int cached = 0;
46 78 int i;
47 printk("\nMem-info:\n"); 79
48 show_free_areas(); 80 printk("\nMem-info:\n");
49 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 81 show_free_areas();
50 i = max_mapnr; 82 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
51 while (i-- > 0) { 83 for_each_online_pgdat(pgdat) {
52 total++; 84 for (i = 0; i < pgdat->node_spanned_pages; i++) {
53 if (PageReserved(mem_map+i)) 85 struct page *page = pgdat->node_mem_map + i;
54 reserved++; 86 total++;
55 else if (PageSwapCache(mem_map+i)) 87 if (PageReserved(page))
56 cached++; 88 reserved++;
57 else if (!page_count(mem_map+i)) 89 else if (PageSwapCache(page))
58 free++; 90 cached++;
59 else 91 else if (!page_count(page))
60 shared += page_count(mem_map+i) - 1; 92 free++;
61 } 93 else
62 printk("%d pages of RAM\n",total); 94 shared += page_count(page) - 1;
63 printk("%d free pages\n",free); 95 }
64 printk("%d reserved pages\n",reserved); 96 }
65 printk("%d pages shared\n",shared); 97 printk("%d pages of RAM\n",total);
66 printk("%d pages swap cached\n",cached); 98 printk("%d free pages\n",free);
99 printk("%d reserved pages\n",reserved);
100 printk("%d pages shared\n",shared);
101 printk("%d pages swap cached\n",cached);
67} 102}
68 103
69extern void init_pointer_table(unsigned long ptable); 104extern void init_pointer_table(unsigned long ptable);
70 105
71/* References to section boundaries */ 106/* References to section boundaries */
72 107
73extern char _text, _etext, _edata, __bss_start, _end; 108extern char _text[], _etext[];
74extern char __init_begin, __init_end; 109extern char __init_begin[], __init_end[];
75 110
76extern pmd_t *zero_pgtable; 111extern pmd_t *zero_pgtable;
77 112
78void __init mem_init(void) 113void __init mem_init(void)
79{ 114{
115 pg_data_t *pgdat;
80 int codepages = 0; 116 int codepages = 0;
81 int datapages = 0; 117 int datapages = 0;
82 int initpages = 0; 118 int initpages = 0;
83 unsigned long tmp;
84#ifndef CONFIG_SUN3
85 int i; 119 int i;
86#endif
87
88 max_mapnr = num_physpages = (((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT);
89 120
90#ifdef CONFIG_ATARI 121#ifdef CONFIG_ATARI
91 if (MACH_IS_ATARI) 122 if (MACH_IS_ATARI)
@@ -93,19 +124,25 @@ void __init mem_init(void)
93#endif 124#endif
94 125
95 /* this will put all memory onto the freelists */ 126 /* this will put all memory onto the freelists */
96 totalram_pages = free_all_bootmem(); 127 totalram_pages = num_physpages = 0;
97 128 for_each_online_pgdat(pgdat) {
98 for (tmp = PAGE_OFFSET ; tmp < (unsigned long)high_memory; tmp += PAGE_SIZE) { 129 num_physpages += pgdat->node_present_pages;
99 if (PageReserved(virt_to_page(tmp))) { 130
100 if (tmp >= (unsigned long)&_text 131 totalram_pages += free_all_bootmem_node(pgdat);
101 && tmp < (unsigned long)&_etext) 132 for (i = 0; i < pgdat->node_spanned_pages; i++) {
133 struct page *page = pgdat->node_mem_map + i;
134 char *addr = page_to_virt(page);
135
136 if (!PageReserved(page))
137 continue;
138 if (addr >= _text &&
139 addr < _etext)
102 codepages++; 140 codepages++;
103 else if (tmp >= (unsigned long) &__init_begin 141 else if (addr >= __init_begin &&
104 && tmp < (unsigned long) &__init_end) 142 addr < __init_end)
105 initpages++; 143 initpages++;
106 else 144 else
107 datapages++; 145 datapages++;
108 continue;
109 } 146 }
110 } 147 }
111 148
@@ -124,7 +161,7 @@ void __init mem_init(void)
124 161
125 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n", 162 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
126 (unsigned long)nr_free_pages() << (PAGE_SHIFT-10), 163 (unsigned long)nr_free_pages() << (PAGE_SHIFT-10),
127 max_mapnr << (PAGE_SHIFT-10), 164 totalram_pages << (PAGE_SHIFT-10),
128 codepages << (PAGE_SHIFT-10), 165 codepages << (PAGE_SHIFT-10),
129 datapages << (PAGE_SHIFT-10), 166 datapages << (PAGE_SHIFT-10),
130 initpages << (PAGE_SHIFT-10)); 167 initpages << (PAGE_SHIFT-10));
diff --git a/arch/m68k/mm/memory.c b/arch/m68k/mm/memory.c
index 13c0b4ad01eb..b7473525b431 100644
--- a/arch/m68k/mm/memory.c
+++ b/arch/m68k/mm/memory.c
@@ -127,67 +127,6 @@ int free_pointer_table (pmd_t *ptable)
127 return 0; 127 return 0;
128} 128}
129 129
130#ifdef DEBUG_INVALID_PTOV
131int mm_inv_cnt = 5;
132#endif
133
134#ifndef CONFIG_SINGLE_MEMORY_CHUNK
135/*
136 * The following two routines map from a physical address to a kernel
137 * virtual address and vice versa.
138 */
139unsigned long mm_vtop(unsigned long vaddr)
140{
141 int i=0;
142 unsigned long voff = (unsigned long)vaddr - PAGE_OFFSET;
143
144 do {
145 if (voff < m68k_memory[i].size) {
146#ifdef DEBUGPV
147 printk ("VTOP(%p)=%lx\n", vaddr,
148 m68k_memory[i].addr + voff);
149#endif
150 return m68k_memory[i].addr + voff;
151 }
152 voff -= m68k_memory[i].size;
153 } while (++i < m68k_num_memory);
154
155 /* As a special case allow `__pa(high_memory)'. */
156 if (voff == 0)
157 return m68k_memory[i-1].addr + m68k_memory[i-1].size;
158
159 return -1;
160}
161EXPORT_SYMBOL(mm_vtop);
162
163unsigned long mm_ptov (unsigned long paddr)
164{
165 int i = 0;
166 unsigned long poff, voff = PAGE_OFFSET;
167
168 do {
169 poff = paddr - m68k_memory[i].addr;
170 if (poff < m68k_memory[i].size) {
171#ifdef DEBUGPV
172 printk ("PTOV(%lx)=%lx\n", paddr, poff + voff);
173#endif
174 return poff + voff;
175 }
176 voff += m68k_memory[i].size;
177 } while (++i < m68k_num_memory);
178
179#ifdef DEBUG_INVALID_PTOV
180 if (mm_inv_cnt > 0) {
181 mm_inv_cnt--;
182 printk("Invalid use of phys_to_virt(0x%lx) at 0x%p!\n",
183 paddr, __builtin_return_address(0));
184 }
185#endif
186 return -1;
187}
188EXPORT_SYMBOL(mm_ptov);
189#endif
190
191/* invalidate page in both caches */ 130/* invalidate page in both caches */
192static inline void clear040(unsigned long paddr) 131static inline void clear040(unsigned long paddr)
193{ 132{
@@ -354,15 +293,3 @@ void cache_push (unsigned long paddr, int len)
354} 293}
355EXPORT_SYMBOL(cache_push); 294EXPORT_SYMBOL(cache_push);
356 295
357#ifndef CONFIG_SINGLE_MEMORY_CHUNK
358int mm_end_of_chunk (unsigned long addr, int len)
359{
360 int i;
361
362 for (i = 0; i < m68k_num_memory; i++)
363 if (m68k_memory[i].addr + m68k_memory[i].size == addr + len)
364 return 1;
365 return 0;
366}
367EXPORT_SYMBOL(mm_end_of_chunk);
368#endif
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index afcccdc6ad45..7d571a2b44dd 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -43,6 +43,11 @@ unsigned long mm_cachebits;
43EXPORT_SYMBOL(mm_cachebits); 43EXPORT_SYMBOL(mm_cachebits);
44#endif 44#endif
45 45
46/* size of memory already mapped in head.S */
47#define INIT_MAPPED_SIZE (4UL<<20)
48
49extern unsigned long availmem;
50
46static pte_t * __init kernel_page_table(void) 51static pte_t * __init kernel_page_table(void)
47{ 52{
48 pte_t *ptablep; 53 pte_t *ptablep;
@@ -98,19 +103,20 @@ static pmd_t * __init kernel_ptr_table(void)
98 return last_pgtable; 103 return last_pgtable;
99} 104}
100 105
101static unsigned long __init 106static void __init map_node(int node)
102map_chunk (unsigned long addr, long size)
103{ 107{
104#define PTRTREESIZE (256*1024) 108#define PTRTREESIZE (256*1024)
105#define ROOTTREESIZE (32*1024*1024) 109#define ROOTTREESIZE (32*1024*1024)
106 static unsigned long virtaddr = PAGE_OFFSET; 110 unsigned long physaddr, virtaddr, size;
107 unsigned long physaddr;
108 pgd_t *pgd_dir; 111 pgd_t *pgd_dir;
109 pmd_t *pmd_dir; 112 pmd_t *pmd_dir;
110 pte_t *pte_dir; 113 pte_t *pte_dir;
111 114
112 physaddr = (addr | m68k_supervisor_cachemode | 115 size = m68k_memory[node].size;
113 _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY); 116 physaddr = m68k_memory[node].addr;
117 virtaddr = (unsigned long)phys_to_virt(physaddr);
118 physaddr |= m68k_supervisor_cachemode |
119 _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY;
114 if (CPU_IS_040_OR_060) 120 if (CPU_IS_040_OR_060)
115 physaddr |= _PAGE_GLOBAL040; 121 physaddr |= _PAGE_GLOBAL040;
116 122
@@ -190,8 +196,6 @@ map_chunk (unsigned long addr, long size)
190#ifdef DEBUG 196#ifdef DEBUG
191 printk("\n"); 197 printk("\n");
192#endif 198#endif
193
194 return virtaddr;
195} 199}
196 200
197/* 201/*
@@ -200,15 +204,16 @@ map_chunk (unsigned long addr, long size)
200 */ 204 */
201void __init paging_init(void) 205void __init paging_init(void)
202{ 206{
203 int chunk;
204 unsigned long mem_avail = 0;
205 unsigned long zones_size[MAX_NR_ZONES] = { 0, }; 207 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
208 unsigned long min_addr, max_addr;
209 unsigned long addr, size, end;
210 int i;
206 211
207#ifdef DEBUG 212#ifdef DEBUG
208 { 213 {
209 extern unsigned long availmem; 214 extern unsigned long availmem;
210 printk ("start of paging_init (%p, %lx, %lx, %lx)\n", 215 printk ("start of paging_init (%p, %lx)\n",
211 kernel_pg_dir, availmem, start_mem, end_mem); 216 kernel_pg_dir, availmem);
212 } 217 }
213#endif 218#endif
214 219
@@ -222,24 +227,62 @@ void __init paging_init(void)
222 pgprot_val(protection_map[i]) |= _PAGE_CACHE040; 227 pgprot_val(protection_map[i]) |= _PAGE_CACHE040;
223 } 228 }
224 229
230 min_addr = m68k_memory[0].addr;
231 max_addr = min_addr + m68k_memory[0].size;
232 for (i = 1; i < m68k_num_memory;) {
233 if (m68k_memory[i].addr < min_addr) {
234 printk("Ignoring memory chunk at 0x%lx:0x%lx before the first chunk\n",
235 m68k_memory[i].addr, m68k_memory[i].size);
236 printk("Fix your bootloader or use a memfile to make use of this area!\n");
237 m68k_num_memory--;
238 memmove(m68k_memory + i, m68k_memory + i + 1,
239 (m68k_num_memory - i) * sizeof(struct mem_info));
240 continue;
241 }
242 addr = m68k_memory[i].addr + m68k_memory[i].size;
243 if (addr > max_addr)
244 max_addr = addr;
245 i++;
246 }
247 m68k_memoffset = min_addr - PAGE_OFFSET;
248 m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6;
249
250 module_fixup(NULL, __start_fixup, __stop_fixup);
251 flush_icache();
252
253 high_memory = phys_to_virt(max_addr);
254
255 min_low_pfn = availmem >> PAGE_SHIFT;
256 max_low_pfn = max_addr >> PAGE_SHIFT;
257
258 for (i = 0; i < m68k_num_memory; i++) {
259 addr = m68k_memory[i].addr;
260 end = addr + m68k_memory[i].size;
261 m68k_setup_node(i);
262 availmem = PAGE_ALIGN(availmem);
263 availmem += init_bootmem_node(NODE_DATA(i),
264 availmem >> PAGE_SHIFT,
265 addr >> PAGE_SHIFT,
266 end >> PAGE_SHIFT);
267 }
268
225 /* 269 /*
226 * Map the physical memory available into the kernel virtual 270 * Map the physical memory available into the kernel virtual
227 * address space. It may allocate some memory for page 271 * address space. First initialize the bootmem allocator with
228 * tables and thus modify availmem. 272 * the memory we already mapped, so map_node() has something
273 * to allocate.
229 */ 274 */
275 addr = m68k_memory[0].addr;
276 size = m68k_memory[0].size;
277 free_bootmem_node(NODE_DATA(0), availmem, min(INIT_MAPPED_SIZE, size) - (availmem - addr));
278 map_node(0);
279 if (size > INIT_MAPPED_SIZE)
280 free_bootmem_node(NODE_DATA(0), addr + INIT_MAPPED_SIZE, size - INIT_MAPPED_SIZE);
230 281
231 for (chunk = 0; chunk < m68k_num_memory; chunk++) { 282 for (i = 1; i < m68k_num_memory; i++)
232 mem_avail = map_chunk (m68k_memory[chunk].addr, 283 map_node(i);
233 m68k_memory[chunk].size);
234
235 }
236 284
237 flush_tlb_all(); 285 flush_tlb_all();
238#ifdef DEBUG
239 printk ("memory available is %ldKB\n", mem_avail >> 10);
240 printk ("start_mem is %#lx\nvirtual_end is %#lx\n",
241 start_mem, end_mem);
242#endif
243 286
244 /* 287 /*
245 * initialize the bad page table and bad page to point 288 * initialize the bad page table and bad page to point
@@ -256,14 +299,11 @@ void __init paging_init(void)
256#ifdef DEBUG 299#ifdef DEBUG
257 printk ("before free_area_init\n"); 300 printk ("before free_area_init\n");
258#endif 301#endif
259 zones_size[ZONE_DMA] = (mach_max_dma_address < (unsigned long)high_memory ? 302 for (i = 0; i < m68k_num_memory; i++) {
260 (mach_max_dma_address+1) : (unsigned long)high_memory); 303 zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
261 zones_size[ZONE_NORMAL] = (unsigned long)high_memory - zones_size[0]; 304 free_area_init_node(i, pg_data_map + i, zones_size,
262 305 m68k_memory[i].addr >> PAGE_SHIFT, NULL);
263 zones_size[ZONE_DMA] = (zones_size[ZONE_DMA] - PAGE_OFFSET) >> PAGE_SHIFT; 306 }
264 zones_size[ZONE_NORMAL] >>= PAGE_SHIFT;
265
266 free_area_init(zones_size);
267} 307}
268 308
269extern char __init_begin, __init_end; 309extern char __init_begin, __init_end;
diff --git a/arch/m68k/sun3/config.c b/arch/m68k/sun3/config.c
index 4851b8437a87..c0fbd278fbb1 100644
--- a/arch/m68k/sun3/config.c
+++ b/arch/m68k/sun3/config.c
@@ -21,6 +21,7 @@
21#include <asm/contregs.h> 21#include <asm/contregs.h>
22#include <asm/movs.h> 22#include <asm/movs.h>
23#include <asm/pgtable.h> 23#include <asm/pgtable.h>
24#include <asm/pgalloc.h>
24#include <asm/sun3-head.h> 25#include <asm/sun3-head.h>
25#include <asm/sun3mmu.h> 26#include <asm/sun3mmu.h>
26#include <asm/rtc.h> 27#include <asm/rtc.h>
@@ -127,6 +128,7 @@ void __init sun3_bootmem_alloc(unsigned long memory_start, unsigned long memory_
127 high_memory = (void *)memory_end; 128 high_memory = (void *)memory_end;
128 availmem = memory_start; 129 availmem = memory_start;
129 130
131 m68k_setup_node(0);
130 availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages); 132 availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
131 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK; 133 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
132 134
diff --git a/arch/mips/jmr3927/rbhma3100/kgdb_io.c b/arch/mips/jmr3927/rbhma3100/kgdb_io.c
index 2604f2c9a96e..342579cfdc01 100644
--- a/arch/mips/jmr3927/rbhma3100/kgdb_io.c
+++ b/arch/mips/jmr3927/rbhma3100/kgdb_io.c
@@ -36,7 +36,7 @@
36#define TIMEOUT 0xffffff 36#define TIMEOUT 0xffffff
37 37
38static int remoteDebugInitialized = 0; 38static int remoteDebugInitialized = 0;
39static void debugInit(int baud) 39static void debugInit(int baud);
40 40
41int putDebugChar(unsigned char c) 41int putDebugChar(unsigned char c)
42{ 42{
diff --git a/arch/mips/pci/pci-ocelot.c b/arch/mips/pci/pci-ocelot.c
index 7f94f26d35ae..1421d34535ef 100644
--- a/arch/mips/pci/pci-ocelot.c
+++ b/arch/mips/pci/pci-ocelot.c
@@ -71,19 +71,19 @@ static inline void pci0WriteConfigReg(unsigned int offset, unsigned int data)
71} 71}
72 72
73static struct resource ocelot_mem_resource = { 73static struct resource ocelot_mem_resource = {
74 start = GT_PCI_MEM_BASE; 74 .start = GT_PCI_MEM_BASE,
75 end = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1; 75 .end = GT_PCI_MEM_BASE + GT_PCI_MEM_BASE - 1,
76}; 76};
77 77
78static struct resource ocelot_io_resource = { 78static struct resource ocelot_io_resource = {
79 start = GT_PCI_IO_BASE; 79 .start = GT_PCI_IO_BASE,
80 end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1; 80 .end = GT_PCI_IO_BASE + GT_PCI_IO_SIZE - 1,
81}; 81};
82 82
83static struct pci_controller ocelot_pci_controller = { 83static struct pci_controller ocelot_pci_controller = {
84 .pci_ops = gt64xxx_pci0_ops; 84 .pci_ops = gt64xxx_pci0_ops,
85 .mem_resource = &ocelot_mem_resource; 85 .mem_resource = &ocelot_mem_resource,
86 .io_resource = &ocelot_io_resource; 86 .io_resource = &ocelot_io_resource,
87}; 87};
88 88
89static int __init ocelot_pcibios_init(void) 89static int __init ocelot_pcibios_init(void)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 56d3c0dcd2b8..5eaeafd30bdf 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -118,6 +118,7 @@ config GENERIC_BUG
118 depends on BUG 118 depends on BUG
119 119
120config SYS_SUPPORTS_APM_EMULATION 120config SYS_SUPPORTS_APM_EMULATION
121 default y if PMAC_APM_EMU
121 bool 122 bool
122 123
123config DEFAULT_UIMAGE 124config DEFAULT_UIMAGE
diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
index eae68ab1177f..d29308fe4c24 100644
--- a/arch/powerpc/boot/dts/lite5200.dts
+++ b/arch/powerpc/boot/dts/lite5200.dts
@@ -67,7 +67,7 @@
67 interrupt-controller; 67 interrupt-controller;
68 #interrupt-cells = <3>; 68 #interrupt-cells = <3>;
69 device_type = "interrupt-controller"; 69 device_type = "interrupt-controller";
70 compatible = "mpc5200_pic"; 70 compatible = "mpc5200-pic";
71 reg = <500 80>; 71 reg = <500 80>;
72 built-in; 72 built-in;
73 }; 73 };
diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
index 5185625a9419..f242531f0451 100644
--- a/arch/powerpc/boot/dts/lite5200b.dts
+++ b/arch/powerpc/boot/dts/lite5200b.dts
@@ -67,7 +67,7 @@
67 interrupt-controller; 67 interrupt-controller;
68 #interrupt-cells = <3>; 68 #interrupt-cells = <3>;
69 device_type = "interrupt-controller"; 69 device_type = "interrupt-controller";
70 compatible = "mpc5200b-pic\0mpc5200_pic"; 70 compatible = "mpc5200b-pic\0mpc5200-pic";
71 reg = <500 80>; 71 reg = <500 80>;
72 built-in; 72 built-in;
73 }; 73 };
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index d8232b7a08f7..f6ae1a57d652 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -93,7 +93,7 @@ void pgd_free(pgd_t *pgd)
93 free_pages((unsigned long)pgd, PGDIR_ORDER); 93 free_pages((unsigned long)pgd, PGDIR_ORDER);
94} 94}
95 95
96pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 96__init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
97{ 97{
98 pte_t *pte; 98 pte_t *pte;
99 extern int mem_init_done; 99 extern int mem_init_done;
diff --git a/arch/powerpc/platforms/chrp/pegasos_eth.c b/arch/powerpc/platforms/chrp/pegasos_eth.c
index 71045677559a..5bcc58d9a4dd 100644
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -169,7 +169,7 @@ static int Enable_SRAM(void)
169 169
170/***********/ 170/***********/
171/***********/ 171/***********/
172int mv643xx_eth_add_pds(void) 172static int __init mv643xx_eth_add_pds(void)
173{ 173{
174 int ret = 0; 174 int ret = 0;
175 static struct pci_device_id pci_marvell_mv64360[] = { 175 static struct pci_device_id pci_marvell_mv64360[] = {
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index a410bc76a8a8..07b1c4ec428d 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -384,7 +384,7 @@ int boot_part;
384static dev_t boot_dev; 384static dev_t boot_dev;
385 385
386#ifdef CONFIG_SCSI 386#ifdef CONFIG_SCSI
387void __init note_scsi_host(struct device_node *node, void *host) 387void note_scsi_host(struct device_node *node, void *host)
388{ 388{
389 int l; 389 int l;
390 char *p; 390 char *p;
diff --git a/arch/powerpc/sysdev/qe_lib/Kconfig b/arch/powerpc/sysdev/qe_lib/Kconfig
index 887739f3badc..f611d344a126 100644
--- a/arch/powerpc/sysdev/qe_lib/Kconfig
+++ b/arch/powerpc/sysdev/qe_lib/Kconfig
@@ -5,15 +5,13 @@
5config UCC_SLOW 5config UCC_SLOW
6 bool 6 bool
7 default n 7 default n
8 select UCC
9 help 8 help
10 This option provides qe_lib support to UCC slow 9 This option provides qe_lib support to UCC slow
11 protocols: UART, BISYNC, QMC 10 protocols: UART, BISYNC, QMC
12 11
13config UCC_FAST 12config UCC_FAST
14 bool 13 bool
15 default n 14 default y if UCC_GETH
16 select UCC
17 help 15 help
18 This option provides qe_lib support to UCC fast 16 This option provides qe_lib support to UCC fast
19 protocols: HDLC, Ethernet, ATM, transparent 17 protocols: HDLC, Ethernet, ATM, transparent
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index ab64256110bd..fba7ca17a67e 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -596,7 +596,11 @@ fast_exception_return:
596 mr r12,r4 /* restart at exc_exit_restart */ 596 mr r12,r4 /* restart at exc_exit_restart */
597 b 2b 597 b 2b
598 598
599 .comm fee_restarts,4 599 .section .bss
600 .align 2
601fee_restarts:
602 .space 4
603 .previous
600 604
601/* aargh, a nonrecoverable interrupt, panic */ 605/* aargh, a nonrecoverable interrupt, panic */
602/* aargh, we don't know which trap this is */ 606/* aargh, we don't know which trap this is */
@@ -851,7 +855,11 @@ load_dbcr0:
851 mtspr SPRN_DBSR,r11 /* clear all pending debug events */ 855 mtspr SPRN_DBSR,r11 /* clear all pending debug events */
852 blr 856 blr
853 857
854 .comm global_dbcr0,8 858 .section .bss
859 .align 4
860global_dbcr0:
861 .space 8
862 .previous
855#endif /* !(CONFIG_4xx || CONFIG_BOOKE) */ 863#endif /* !(CONFIG_4xx || CONFIG_BOOKE) */
856 864
857do_work: /* r10 contains MSR_KERNEL here */ 865do_work: /* r10 contains MSR_KERNEL here */
@@ -926,4 +934,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_601)
926 /* shouldn't return */ 934 /* shouldn't return */
927 b 4b 935 b 4b
928 936
929 .comm ee_restarts,4 937 .section .bss
938 .align 2
939ee_restarts:
940 .space 4
941 .previous
diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
index 4ad499605d05..a4165209ac7c 100644
--- a/arch/ppc/kernel/ppc_ksyms.c
+++ b/arch/ppc/kernel/ppc_ksyms.c
@@ -40,7 +40,6 @@
40#include <asm/time.h> 40#include <asm/time.h>
41#include <asm/cputable.h> 41#include <asm/cputable.h>
42#include <asm/btext.h> 42#include <asm/btext.h>
43#include <asm/div64.h>
44#include <asm/xmon.h> 43#include <asm/xmon.h>
45#include <asm/signal.h> 44#include <asm/signal.h>
46#include <asm/dcr.h> 45#include <asm/dcr.h>
@@ -93,7 +92,6 @@ EXPORT_SYMBOL(strncpy);
93EXPORT_SYMBOL(strcat); 92EXPORT_SYMBOL(strcat);
94EXPORT_SYMBOL(strlen); 93EXPORT_SYMBOL(strlen);
95EXPORT_SYMBOL(strcmp); 94EXPORT_SYMBOL(strcmp);
96EXPORT_SYMBOL(__div64_32);
97 95
98EXPORT_SYMBOL(csum_partial); 96EXPORT_SYMBOL(csum_partial);
99EXPORT_SYMBOL(csum_partial_copy_generic); 97EXPORT_SYMBOL(csum_partial_copy_generic);
diff --git a/arch/ppc/mm/hashtable.S b/arch/ppc/mm/hashtable.S
index e756942e65c4..5f364dc50154 100644
--- a/arch/ppc/mm/hashtable.S
+++ b/arch/ppc/mm/hashtable.S
@@ -30,7 +30,11 @@
30#include <asm/asm-offsets.h> 30#include <asm/asm-offsets.h>
31 31
32#ifdef CONFIG_SMP 32#ifdef CONFIG_SMP
33 .comm mmu_hash_lock,4 33 .section .bss
34 .align 2
35 .globl mmu_hash_lock
36mmu_hash_lock:
37 .space 4
34#endif /* CONFIG_SMP */ 38#endif /* CONFIG_SMP */
35 39
36/* 40/*
@@ -461,9 +465,17 @@ found_slot:
461 sync /* make sure pte updates get to memory */ 465 sync /* make sure pte updates get to memory */
462 blr 466 blr
463 467
464 .comm next_slot,4 468 .section .bss
465 .comm primary_pteg_full,4 469 .align 2
466 .comm htab_hash_searches,4 470next_slot:
471 .space 4
472 .globl primary_pteg_full
473primary_pteg_full:
474 .space 4
475 .globl htab_hash_searches
476htab_hash_searches:
477 .space 4
478 .previous
467 479
468/* 480/*
469 * Flush the entry for a particular page from the hash table. 481 * Flush the entry for a particular page from the hash table.
diff --git a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
index c023b7298809..35ebb6395ae3 100644
--- a/arch/ppc/mm/pgtable.c
+++ b/arch/ppc/mm/pgtable.c
@@ -92,7 +92,7 @@ void pgd_free(pgd_t *pgd)
92 free_pages((unsigned long)pgd, PGDIR_ORDER); 92 free_pages((unsigned long)pgd, PGDIR_ORDER);
93} 93}
94 94
95pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 95__init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
96{ 96{
97 pte_t *pte; 97 pte_t *pte;
98 extern int mem_init_done; 98 extern int mem_init_done;
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index 2782cf9da5b4..b9a1ce1f28e4 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -481,9 +481,17 @@ out:
481 481
482/* Diagnose 224 functions */ 482/* Diagnose 224 functions */
483 483
484static void diag224(void *ptr) 484static int diag224(void *ptr)
485{ 485{
486 asm volatile("diag %0,%1,0x224" : :"d" (0), "d"(ptr) : "memory"); 486 int rc = -ENOTSUPP;
487
488 asm volatile(
489 " diag %1,%2,0x224\n"
490 "0: lhi %0,0x0\n"
491 "1:\n"
492 EX_TABLE(0b,1b)
493 : "+d" (rc) :"d" (0), "d" (ptr) : "memory");
494 return rc;
487} 495}
488 496
489static int diag224_get_name_table(void) 497static int diag224_get_name_table(void)
@@ -492,7 +500,10 @@ static int diag224_get_name_table(void)
492 diag224_cpu_names = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA); 500 diag224_cpu_names = kmalloc(PAGE_SIZE, GFP_KERNEL | GFP_DMA);
493 if (!diag224_cpu_names) 501 if (!diag224_cpu_names)
494 return -ENOMEM; 502 return -ENOMEM;
495 diag224(diag224_cpu_names); 503 if (diag224(diag224_cpu_names)) {
504 kfree(diag224_cpu_names);
505 return -ENOTSUPP;
506 }
496 EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16); 507 EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
497 return 0; 508 return 0;
498} 509}
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index dca6eaf82c80..1b2f5ce45320 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -163,7 +163,7 @@ unsigned int debug_feature_version = __DEBUG_FEATURE_VERSION;
163 163
164static debug_info_t *debug_area_first = NULL; 164static debug_info_t *debug_area_first = NULL;
165static debug_info_t *debug_area_last = NULL; 165static debug_info_t *debug_area_last = NULL;
166static DECLARE_MUTEX(debug_lock); 166static DEFINE_MUTEX(debug_mutex);
167 167
168static int initialized; 168static int initialized;
169 169
@@ -576,7 +576,7 @@ debug_input(struct file *file, const char __user *user_buf, size_t length,
576 int rc = 0; 576 int rc = 0;
577 file_private_info_t *p_info; 577 file_private_info_t *p_info;
578 578
579 down(&debug_lock); 579 mutex_lock(&debug_mutex);
580 p_info = ((file_private_info_t *) file->private_data); 580 p_info = ((file_private_info_t *) file->private_data);
581 if (p_info->view->input_proc) 581 if (p_info->view->input_proc)
582 rc = p_info->view->input_proc(p_info->debug_info_org, 582 rc = p_info->view->input_proc(p_info->debug_info_org,
@@ -584,7 +584,7 @@ debug_input(struct file *file, const char __user *user_buf, size_t length,
584 length, offset); 584 length, offset);
585 else 585 else
586 rc = -EPERM; 586 rc = -EPERM;
587 up(&debug_lock); 587 mutex_unlock(&debug_mutex);
588 return rc; /* number of input characters */ 588 return rc; /* number of input characters */
589} 589}
590 590
@@ -602,7 +602,7 @@ debug_open(struct inode *inode, struct file *file)
602 file_private_info_t *p_info; 602 file_private_info_t *p_info;
603 debug_info_t *debug_info, *debug_info_snapshot; 603 debug_info_t *debug_info, *debug_info_snapshot;
604 604
605 down(&debug_lock); 605 mutex_lock(&debug_mutex);
606 debug_info = file->f_path.dentry->d_inode->i_private; 606 debug_info = file->f_path.dentry->d_inode->i_private;
607 /* find debug view */ 607 /* find debug view */
608 for (i = 0; i < DEBUG_MAX_VIEWS; i++) { 608 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
@@ -653,7 +653,7 @@ found:
653 file->private_data = p_info; 653 file->private_data = p_info;
654 debug_info_get(debug_info); 654 debug_info_get(debug_info);
655out: 655out:
656 up(&debug_lock); 656 mutex_unlock(&debug_mutex);
657 return rc; 657 return rc;
658} 658}
659 659
@@ -688,7 +688,7 @@ debug_register (char *name, int pages_per_area, int nr_areas, int buf_size)
688 688
689 if (!initialized) 689 if (!initialized)
690 BUG(); 690 BUG();
691 down(&debug_lock); 691 mutex_lock(&debug_mutex);
692 692
693 /* create new debug_info */ 693 /* create new debug_info */
694 694
@@ -702,7 +702,7 @@ out:
702 if (!rc){ 702 if (!rc){
703 printk(KERN_ERR "debug: debug_register failed for %s\n",name); 703 printk(KERN_ERR "debug: debug_register failed for %s\n",name);
704 } 704 }
705 up(&debug_lock); 705 mutex_unlock(&debug_mutex);
706 return rc; 706 return rc;
707} 707}
708 708
@@ -716,9 +716,9 @@ debug_unregister(debug_info_t * id)
716{ 716{
717 if (!id) 717 if (!id)
718 goto out; 718 goto out;
719 down(&debug_lock); 719 mutex_lock(&debug_mutex);
720 debug_info_put(id); 720 debug_info_put(id);
721 up(&debug_lock); 721 mutex_unlock(&debug_mutex);
722 722
723out: 723out:
724 return; 724 return;
@@ -1054,11 +1054,11 @@ __init debug_init(void)
1054 int rc = 0; 1054 int rc = 0;
1055 1055
1056 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table); 1056 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
1057 down(&debug_lock); 1057 mutex_lock(&debug_mutex);
1058 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL); 1058 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL);
1059 printk(KERN_INFO "debug: Initialization complete\n"); 1059 printk(KERN_INFO "debug: Initialization complete\n");
1060 initialized = 1; 1060 initialized = 1;
1061 up(&debug_lock); 1061 mutex_unlock(&debug_mutex);
1062 1062
1063 return rc; 1063 return rc;
1064} 1064}
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 6bfb0889eb10..51d6309e7f3b 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -102,7 +102,7 @@ static struct resource data_resource = {
102/* 102/*
103 * cpu_init() initializes state that is per-CPU. 103 * cpu_init() initializes state that is per-CPU.
104 */ 104 */
105void __devinit cpu_init (void) 105void __cpuinit cpu_init(void)
106{ 106{
107 int addr = hard_smp_processor_id(); 107 int addr = hard_smp_processor_id();
108 108
@@ -915,7 +915,7 @@ setup_arch(char **cmdline_p)
915 setup_zfcpdump(console_devno); 915 setup_zfcpdump(console_devno);
916} 916}
917 917
918void print_cpu_info(struct cpuinfo_S390 *cpuinfo) 918void __cpuinit print_cpu_info(struct cpuinfo_S390 *cpuinfo)
919{ 919{
920 printk("cpu %d " 920 printk("cpu %d "
921#ifdef CONFIG_SMP 921#ifdef CONFIG_SMP
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 09f028a3266b..8ff2feaf9b00 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -492,7 +492,7 @@ static unsigned int __init smp_count_cpus(void)
492/* 492/*
493 * Activate a secondary processor. 493 * Activate a secondary processor.
494 */ 494 */
495int __devinit start_secondary(void *cpuvoid) 495int __cpuinit start_secondary(void *cpuvoid)
496{ 496{
497 /* Setup the cpu */ 497 /* Setup the cpu */
498 cpu_init(); 498 cpu_init();
@@ -741,7 +741,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
741 smp_create_idle(cpu); 741 smp_create_idle(cpu);
742} 742}
743 743
744void __devinit smp_prepare_boot_cpu(void) 744void __init smp_prepare_boot_cpu(void)
745{ 745{
746 BUG_ON(smp_processor_id() != 0); 746 BUG_ON(smp_processor_id() != 0);
747 747
@@ -750,7 +750,7 @@ void __devinit smp_prepare_boot_cpu(void)
750 current_set[0] = current; 750 current_set[0] = current;
751} 751}
752 752
753void smp_cpus_done(unsigned int max_cpus) 753void __init smp_cpus_done(unsigned int max_cpus)
754{ 754{
755 cpu_present_map = cpu_possible_map; 755 cpu_present_map = cpu_possible_map;
756} 756}
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 7b1122417050..883b03b040c4 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -39,7 +39,7 @@ cflags-$(CONFIG_CPU_SH2A) := -m2a $(call cc-option,-m2a-nofpu,)
39cflags-$(CONFIG_CPU_SH3) := -m3 39cflags-$(CONFIG_CPU_SH3) := -m3
40cflags-$(CONFIG_CPU_SH4) := -m4 \ 40cflags-$(CONFIG_CPU_SH4) := -m4 \
41 $(call cc-option,-mno-implicit-fp,-m4-nofpu) 41 $(call cc-option,-mno-implicit-fp,-m4-nofpu)
42cflags-$(CONFIG_CPU_SH4A) := -m4a $(call cc-option,-m4a-nofpu,) 42cflags-$(CONFIG_CPU_SH4A) := $(call cc-option,-m4a,) $(call cc-option,-m4a-nofpu,)
43 43
44cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb 44cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
45cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml 45cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index 8057a27a1bc6..cf8e11994330 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -16,6 +16,7 @@
16#include <linux/list.h> 16#include <linux/list.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/sched.h>
19#include <asm/dma.h> 20#include <asm/dma.h>
20 21
21DEFINE_SPINLOCK(dma_spin_lock); 22DEFINE_SPINLOCK(dma_spin_lock);
diff --git a/arch/sh/kernel/cf-enabler.c b/arch/sh/kernel/cf-enabler.c
index 849a9e191391..ebc73b85094a 100644
--- a/arch/sh/kernel/cf-enabler.c
+++ b/arch/sh/kernel/cf-enabler.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/vmalloc.h> 14#include <linux/vmalloc.h>
15#include <linux/interrupt.h>
15#include <asm/io.h> 16#include <asm/io.h>
16#include <asm/irq.h> 17#include <asm/irq.h>
17 18
@@ -149,6 +150,11 @@ static int __init cf_init_se(void)
149 ctrl_outb(0x42, PA_MRSHPC_MW2 + 0x200); 150 ctrl_outb(0x42, PA_MRSHPC_MW2 + 0x200);
150 return 0; 151 return 0;
151} 152}
153#else
154static int __init cf_init_se(void)
155{
156 return -1;
157}
152#endif 158#endif
153 159
154int __init cf_init(void) 160int __init cf_init(void)
diff --git a/arch/sh/kernel/cpu/sh3/entry.S b/arch/sh/kernel/cpu/sh3/entry.S
index 832c0b4a1e6c..659cc081e5e7 100644
--- a/arch/sh/kernel/cpu/sh3/entry.S
+++ b/arch/sh/kernel/cpu/sh3/entry.S
@@ -320,6 +320,7 @@ skip_restore:
320 320
321 .align 2 321 .align 2
3225: .long 0x00001000 ! DSP 3225: .long 0x00001000 ! DSP
3236: .long in_nmi
3237: .long 0x30000000 3247: .long 0x30000000
324 325
325! common exception handler 326! common exception handler
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index 8cd04904c77a..fab2eb07196b 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -12,6 +12,7 @@
12 */ 12 */
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/smp.h>
15#include <asm/processor.h> 16#include <asm/processor.h>
16#include <asm/cache.h> 17#include <asm/cache.h>
17 18
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index dbebaddcfe39..283e1425ced5 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -10,6 +10,8 @@
10 * Free Software Foundation; either version 2 of the License, or (at your 10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
12 */ 12 */
13
14#include <linux/err.h>
13#include <linux/cache.h> 15#include <linux/cache.h>
14#include <linux/cpumask.h> 16#include <linux/cpumask.h>
15#include <linux/delay.h> 17#include <linux/delay.h>
diff --git a/arch/sh/kernel/timers/timer.c b/arch/sh/kernel/timers/timer.c
index a6bcc913d25e..4e7e747d1b69 100644
--- a/arch/sh/kernel/timers/timer.c
+++ b/arch/sh/kernel/timers/timer.c
@@ -13,7 +13,7 @@
13#include <linux/string.h> 13#include <linux/string.h>
14#include <asm/timer.h> 14#include <asm/timer.h>
15 15
16static struct sys_timer *sys_timers[] __initdata = { 16static struct sys_timer *sys_timers[] = {
17#ifdef CONFIG_SH_TMU 17#ifdef CONFIG_SH_TMU
18 &tmu_timer, 18 &tmu_timer,
19#endif 19#endif
@@ -26,7 +26,7 @@ static struct sys_timer *sys_timers[] __initdata = {
26 NULL, 26 NULL,
27}; 27};
28 28
29static char timer_override[10] __initdata; 29static char timer_override[10];
30static int __init timer_setup(char *str) 30static int __init timer_setup(char *str)
31{ 31{
32 if (str) 32 if (str)
@@ -53,4 +53,3 @@ struct sys_timer *get_sys_timer(void)
53 53
54 return NULL; 54 return NULL;
55} 55}
56
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index e146bafcd14f..2aa9438361bc 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -17,6 +17,7 @@
17#include <linux/gfp.h> 17#include <linux/gfp.h>
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/elf.h> 19#include <linux/elf.h>
20#include <linux/sched.h>
20 21
21/* 22/*
22 * Should the kernel map a VDSO page into processes and pass its 23 * Should the kernel map a VDSO page into processes and pass its
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index bd992c0048f0..fbcc00c6c06e 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -178,6 +178,13 @@ config ARCH_HAS_ILOG2_U64
178 bool 178 bool
179 default n 179 default n
180 180
181config EMULATED_CMPXCHG
182 bool
183 default y
184 help
185 Sparc32 does not have a CAS instruction like sparc64. cmpxchg()
186 is emulated, and therefore it is not completely atomic.
187
181config SUN_PM 188config SUN_PM
182 bool 189 bool
183 default y 190 default y
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index f1401b57ccc7..7b4612da74a6 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -148,7 +148,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
148} 148}
149 149
150/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ 150/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */
151static void __init kick_start_clock(void) 151static void __devinit kick_start_clock(void)
152{ 152{
153 struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs; 153 struct mostek48t02 *regs = (struct mostek48t02 *)mstk48t02_regs;
154 unsigned char sec; 154 unsigned char sec;
@@ -223,7 +223,7 @@ static __inline__ int has_low_battery(void)
223 return (data1 == data2); /* Was the write blocked? */ 223 return (data1 == data2); /* Was the write blocked? */
224} 224}
225 225
226static void __init mostek_set_system_time(void) 226static void __devinit mostek_set_system_time(void)
227{ 227{
228 unsigned int year, mon, day, hour, min, sec; 228 unsigned int year, mon, day, hour, min, sec;
229 struct mostek48t02 *mregs; 229 struct mostek48t02 *mregs;
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c
index 559335f4917d..cbddeb38ffda 100644
--- a/arch/sparc/lib/atomic32.c
+++ b/arch/sparc/lib/atomic32.c
@@ -2,6 +2,7 @@
2 * atomic32.c: 32-bit atomic_t implementation 2 * atomic32.c: 32-bit atomic_t implementation
3 * 3 *
4 * Copyright (C) 2004 Keith M Wesolowski 4 * Copyright (C) 2004 Keith M Wesolowski
5 * Copyright (C) 2007 Kyle McMartin
5 * 6 *
6 * Based on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf 7 * Based on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf
7 */ 8 */
@@ -117,3 +118,17 @@ unsigned long ___change_bit(unsigned long *addr, unsigned long mask)
117 return old & mask; 118 return old & mask;
118} 119}
119EXPORT_SYMBOL(___change_bit); 120EXPORT_SYMBOL(___change_bit);
121
122unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new)
123{
124 unsigned long flags;
125 u32 prev;
126
127 spin_lock_irqsave(ATOMIC_HASH(ptr), flags);
128 if ((prev = *ptr) == old)
129 *ptr = new;
130 spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);
131
132 return (unsigned long)prev;
133}
134EXPORT_SYMBOL(__cmpxchg_u32);
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 831781cab271..bd00f89eed1e 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -147,10 +147,10 @@ config SMP
147 If you don't know what to do here, say N. 147 If you don't know what to do here, say N.
148 148
149config NR_CPUS 149config NR_CPUS
150 int "Maximum number of CPUs (2-64)" 150 int "Maximum number of CPUs (2-1024)"
151 range 2 64 151 range 2 1024
152 depends on SMP 152 depends on SMP
153 default "32" 153 default "64"
154 154
155source "drivers/cpufreq/Kconfig" 155source "drivers/cpufreq/Kconfig"
156 156
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index c749dccacc32..d8d19093d12f 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -8,11 +8,11 @@ EXTRA_CFLAGS := -Werror
8extra-y := head.o init_task.o vmlinux.lds 8extra-y := head.o init_task.o vmlinux.lds
9 9
10obj-y := process.o setup.o cpu.o idprom.o \ 10obj-y := process.o setup.o cpu.o idprom.o \
11 traps.o devices.o auxio.o una_asm.o \ 11 traps.o auxio.o una_asm.o \
12 irq.o ptrace.o time.o sys_sparc.o signal.o \ 12 irq.o ptrace.o time.o sys_sparc.o signal.o \
13 unaligned.o central.o pci.o starfire.o semaphore.o \ 13 unaligned.o central.o pci.o starfire.o semaphore.o \
14 power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \ 14 power.o sbus.o iommu_common.o sparc64_ksyms.o chmc.o \
15 visemul.o prom.o of_device.o hvapi.o 15 visemul.o prom.o of_device.o hvapi.o sstate.o mdesc.o
16 16
17obj-$(CONFIG_STACKTRACE) += stacktrace.o 17obj-$(CONFIG_STACKTRACE) += stacktrace.o
18obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \ 18obj-$(CONFIG_PCI) += ebus.o isa.o pci_common.o pci_iommu.o \
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c
deleted file mode 100644
index 0e03c8e218cd..000000000000
--- a/arch/sparc64/kernel/devices.c
+++ /dev/null
@@ -1,196 +0,0 @@
1/* devices.c: Initial scan of the prom device tree for important
2 * Sparc device nodes which we need to find.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7#include <linux/kernel.h>
8#include <linux/threads.h>
9#include <linux/init.h>
10#include <linux/ioport.h>
11#include <linux/string.h>
12#include <linux/spinlock.h>
13#include <linux/errno.h>
14#include <linux/bootmem.h>
15
16#include <asm/page.h>
17#include <asm/oplib.h>
18#include <asm/system.h>
19#include <asm/smp.h>
20#include <asm/spitfire.h>
21#include <asm/timer.h>
22#include <asm/cpudata.h>
23
24/* Used to synchronize accesses to NatSemi SUPER I/O chip configure
25 * operations in asm/ns87303.h
26 */
27DEFINE_SPINLOCK(ns87303_lock);
28
29extern void cpu_probe(void);
30extern void central_probe(void);
31
32static const char *cpu_mid_prop(void)
33{
34 if (tlb_type == spitfire)
35 return "upa-portid";
36 return "portid";
37}
38
39static int get_cpu_mid(struct device_node *dp)
40{
41 struct property *prop;
42
43 if (tlb_type == hypervisor) {
44 struct linux_prom64_registers *reg;
45 int len;
46
47 prop = of_find_property(dp, "cpuid", &len);
48 if (prop && len == 4)
49 return *(int *) prop->value;
50
51 prop = of_find_property(dp, "reg", NULL);
52 reg = prop->value;
53 return (reg[0].phys_addr >> 32) & 0x0fffffffUL;
54 } else {
55 const char *prop_name = cpu_mid_prop();
56
57 prop = of_find_property(dp, prop_name, NULL);
58 if (prop)
59 return *(int *) prop->value;
60 return 0;
61 }
62}
63
64static int check_cpu_node(struct device_node *dp, int *cur_inst,
65 int (*compare)(struct device_node *, int, void *),
66 void *compare_arg,
67 struct device_node **dev_node, int *mid)
68{
69 if (!compare(dp, *cur_inst, compare_arg)) {
70 if (dev_node)
71 *dev_node = dp;
72 if (mid)
73 *mid = get_cpu_mid(dp);
74 return 0;
75 }
76
77 (*cur_inst)++;
78
79 return -ENODEV;
80}
81
82static int __cpu_find_by(int (*compare)(struct device_node *, int, void *),
83 void *compare_arg,
84 struct device_node **dev_node, int *mid)
85{
86 struct device_node *dp;
87 int cur_inst;
88
89 cur_inst = 0;
90 for_each_node_by_type(dp, "cpu") {
91 int err = check_cpu_node(dp, &cur_inst,
92 compare, compare_arg,
93 dev_node, mid);
94 if (err == 0)
95 return 0;
96 }
97
98 return -ENODEV;
99}
100
101static int cpu_instance_compare(struct device_node *dp, int instance, void *_arg)
102{
103 int desired_instance = (int) (long) _arg;
104
105 if (instance == desired_instance)
106 return 0;
107 return -ENODEV;
108}
109
110int cpu_find_by_instance(int instance, struct device_node **dev_node, int *mid)
111{
112 return __cpu_find_by(cpu_instance_compare, (void *)(long)instance,
113 dev_node, mid);
114}
115
116static int cpu_mid_compare(struct device_node *dp, int instance, void *_arg)
117{
118 int desired_mid = (int) (long) _arg;
119 int this_mid;
120
121 this_mid = get_cpu_mid(dp);
122 if (this_mid == desired_mid)
123 return 0;
124 return -ENODEV;
125}
126
127int cpu_find_by_mid(int mid, struct device_node **dev_node)
128{
129 return __cpu_find_by(cpu_mid_compare, (void *)(long)mid,
130 dev_node, NULL);
131}
132
133void __init device_scan(void)
134{
135 /* FIX ME FAST... -DaveM */
136 ioport_resource.end = 0xffffffffffffffffUL;
137
138 prom_printf("Booting Linux...\n");
139
140#ifndef CONFIG_SMP
141 {
142 struct device_node *dp;
143 int err, def;
144
145 err = cpu_find_by_instance(0, &dp, NULL);
146 if (err) {
147 prom_printf("No cpu nodes, cannot continue\n");
148 prom_halt();
149 }
150 cpu_data(0).clock_tick =
151 of_getintprop_default(dp, "clock-frequency", 0);
152
153 def = ((tlb_type == hypervisor) ?
154 (8 * 1024) :
155 (16 * 1024));
156 cpu_data(0).dcache_size = of_getintprop_default(dp,
157 "dcache-size",
158 def);
159
160 def = 32;
161 cpu_data(0).dcache_line_size =
162 of_getintprop_default(dp, "dcache-line-size", def);
163
164 def = 16 * 1024;
165 cpu_data(0).icache_size = of_getintprop_default(dp,
166 "icache-size",
167 def);
168
169 def = 32;
170 cpu_data(0).icache_line_size =
171 of_getintprop_default(dp, "icache-line-size", def);
172
173 def = ((tlb_type == hypervisor) ?
174 (3 * 1024 * 1024) :
175 (4 * 1024 * 1024));
176 cpu_data(0).ecache_size = of_getintprop_default(dp,
177 "ecache-size",
178 def);
179
180 def = 64;
181 cpu_data(0).ecache_line_size =
182 of_getintprop_default(dp, "ecache-line-size", def);
183 printk("CPU[0]: Caches "
184 "D[sz(%d):line_sz(%d)] "
185 "I[sz(%d):line_sz(%d)] "
186 "E[sz(%d):line_sz(%d)]\n",
187 cpu_data(0).dcache_size, cpu_data(0).dcache_line_size,
188 cpu_data(0).icache_size, cpu_data(0).icache_line_size,
189 cpu_data(0).ecache_size, cpu_data(0).ecache_line_size);
190 }
191#endif
192
193 central_probe();
194
195 cpu_probe();
196}
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index 732b77cb71f8..ed712e0b3372 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -1725,96 +1725,142 @@ real_hard_smp_processor_id:
1725 * returns %o0: sysino 1725 * returns %o0: sysino
1726 */ 1726 */
1727 .globl sun4v_devino_to_sysino 1727 .globl sun4v_devino_to_sysino
1728 .type sun4v_devino_to_sysino,#function
1728sun4v_devino_to_sysino: 1729sun4v_devino_to_sysino:
1729 mov HV_FAST_INTR_DEVINO2SYSINO, %o5 1730 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
1730 ta HV_FAST_TRAP 1731 ta HV_FAST_TRAP
1731 retl 1732 retl
1732 mov %o1, %o0 1733 mov %o1, %o0
1734 .size sun4v_devino_to_sysino, .-sun4v_devino_to_sysino
1733 1735
1734 /* %o0: sysino 1736 /* %o0: sysino
1735 * 1737 *
1736 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 1738 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1737 */ 1739 */
1738 .globl sun4v_intr_getenabled 1740 .globl sun4v_intr_getenabled
1741 .type sun4v_intr_getenabled,#function
1739sun4v_intr_getenabled: 1742sun4v_intr_getenabled:
1740 mov HV_FAST_INTR_GETENABLED, %o5 1743 mov HV_FAST_INTR_GETENABLED, %o5
1741 ta HV_FAST_TRAP 1744 ta HV_FAST_TRAP
1742 retl 1745 retl
1743 mov %o1, %o0 1746 mov %o1, %o0
1747 .size sun4v_intr_getenabled, .-sun4v_intr_getenabled
1744 1748
1745 /* %o0: sysino 1749 /* %o0: sysino
1746 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED}) 1750 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1747 */ 1751 */
1748 .globl sun4v_intr_setenabled 1752 .globl sun4v_intr_setenabled
1753 .type sun4v_intr_setenabled,#function
1749sun4v_intr_setenabled: 1754sun4v_intr_setenabled:
1750 mov HV_FAST_INTR_SETENABLED, %o5 1755 mov HV_FAST_INTR_SETENABLED, %o5
1751 ta HV_FAST_TRAP 1756 ta HV_FAST_TRAP
1752 retl 1757 retl
1753 nop 1758 nop
1759 .size sun4v_intr_setenabled, .-sun4v_intr_setenabled
1754 1760
1755 /* %o0: sysino 1761 /* %o0: sysino
1756 * 1762 *
1757 * returns %o0: intr_state (HV_INTR_STATE_*) 1763 * returns %o0: intr_state (HV_INTR_STATE_*)
1758 */ 1764 */
1759 .globl sun4v_intr_getstate 1765 .globl sun4v_intr_getstate
1766 .type sun4v_intr_getstate,#function
1760sun4v_intr_getstate: 1767sun4v_intr_getstate:
1761 mov HV_FAST_INTR_GETSTATE, %o5 1768 mov HV_FAST_INTR_GETSTATE, %o5
1762 ta HV_FAST_TRAP 1769 ta HV_FAST_TRAP
1763 retl 1770 retl
1764 mov %o1, %o0 1771 mov %o1, %o0
1772 .size sun4v_intr_getstate, .-sun4v_intr_getstate
1765 1773
1766 /* %o0: sysino 1774 /* %o0: sysino
1767 * %o1: intr_state (HV_INTR_STATE_*) 1775 * %o1: intr_state (HV_INTR_STATE_*)
1768 */ 1776 */
1769 .globl sun4v_intr_setstate 1777 .globl sun4v_intr_setstate
1778 .type sun4v_intr_setstate,#function
1770sun4v_intr_setstate: 1779sun4v_intr_setstate:
1771 mov HV_FAST_INTR_SETSTATE, %o5 1780 mov HV_FAST_INTR_SETSTATE, %o5
1772 ta HV_FAST_TRAP 1781 ta HV_FAST_TRAP
1773 retl 1782 retl
1774 nop 1783 nop
1784 .size sun4v_intr_setstate, .-sun4v_intr_setstate
1775 1785
1776 /* %o0: sysino 1786 /* %o0: sysino
1777 * 1787 *
1778 * returns %o0: cpuid 1788 * returns %o0: cpuid
1779 */ 1789 */
1780 .globl sun4v_intr_gettarget 1790 .globl sun4v_intr_gettarget
1791 .type sun4v_intr_gettarget,#function
1781sun4v_intr_gettarget: 1792sun4v_intr_gettarget:
1782 mov HV_FAST_INTR_GETTARGET, %o5 1793 mov HV_FAST_INTR_GETTARGET, %o5
1783 ta HV_FAST_TRAP 1794 ta HV_FAST_TRAP
1784 retl 1795 retl
1785 mov %o1, %o0 1796 mov %o1, %o0
1797 .size sun4v_intr_gettarget, .-sun4v_intr_gettarget
1786 1798
1787 /* %o0: sysino 1799 /* %o0: sysino
1788 * %o1: cpuid 1800 * %o1: cpuid
1789 */ 1801 */
1790 .globl sun4v_intr_settarget 1802 .globl sun4v_intr_settarget
1803 .type sun4v_intr_settarget,#function
1791sun4v_intr_settarget: 1804sun4v_intr_settarget:
1792 mov HV_FAST_INTR_SETTARGET, %o5 1805 mov HV_FAST_INTR_SETTARGET, %o5
1793 ta HV_FAST_TRAP 1806 ta HV_FAST_TRAP
1794 retl 1807 retl
1795 nop 1808 nop
1809 .size sun4v_intr_settarget, .-sun4v_intr_settarget
1796 1810
1797 /* %o0: type 1811 /* %o0: cpuid
1798 * %o1: queue paddr 1812 * %o1: pc
1799 * %o2: num queue entries 1813 * %o2: rtba
1814 * %o3: arg0
1800 * 1815 *
1801 * returns %o0: status 1816 * returns %o0: status
1802 */ 1817 */
1803 .globl sun4v_cpu_qconf 1818 .globl sun4v_cpu_start
1804sun4v_cpu_qconf: 1819 .type sun4v_cpu_start,#function
1805 mov HV_FAST_CPU_QCONF, %o5 1820sun4v_cpu_start:
1821 mov HV_FAST_CPU_START, %o5
1806 ta HV_FAST_TRAP 1822 ta HV_FAST_TRAP
1807 retl 1823 retl
1808 nop 1824 nop
1825 .size sun4v_cpu_start, .-sun4v_cpu_start
1809 1826
1810 /* returns %o0: status 1827 /* %o0: cpuid
1828 *
1829 * returns %o0: status
1811 */ 1830 */
1831 .globl sun4v_cpu_stop
1832 .type sun4v_cpu_stop,#function
1833sun4v_cpu_stop:
1834 mov HV_FAST_CPU_STOP, %o5
1835 ta HV_FAST_TRAP
1836 retl
1837 nop
1838 .size sun4v_cpu_stop, .-sun4v_cpu_stop
1839
1840 /* returns %o0: status */
1812 .globl sun4v_cpu_yield 1841 .globl sun4v_cpu_yield
1842 .type sun4v_cpu_yield, #function
1813sun4v_cpu_yield: 1843sun4v_cpu_yield:
1814 mov HV_FAST_CPU_YIELD, %o5 1844 mov HV_FAST_CPU_YIELD, %o5
1815 ta HV_FAST_TRAP 1845 ta HV_FAST_TRAP
1816 retl 1846 retl
1817 nop 1847 nop
1848 .size sun4v_cpu_yield, .-sun4v_cpu_yield
1849
1850 /* %o0: type
1851 * %o1: queue paddr
1852 * %o2: num queue entries
1853 *
1854 * returns %o0: status
1855 */
1856 .globl sun4v_cpu_qconf
1857 .type sun4v_cpu_qconf,#function
1858sun4v_cpu_qconf:
1859 mov HV_FAST_CPU_QCONF, %o5
1860 ta HV_FAST_TRAP
1861 retl
1862 nop
1863 .size sun4v_cpu_qconf, .-sun4v_cpu_qconf
1818 1864
1819 /* %o0: num cpus in cpu list 1865 /* %o0: num cpus in cpu list
1820 * %o1: cpu list paddr 1866 * %o1: cpu list paddr
@@ -1823,11 +1869,13 @@ sun4v_cpu_yield:
1823 * returns %o0: status 1869 * returns %o0: status
1824 */ 1870 */
1825 .globl sun4v_cpu_mondo_send 1871 .globl sun4v_cpu_mondo_send
1872 .type sun4v_cpu_mondo_send,#function
1826sun4v_cpu_mondo_send: 1873sun4v_cpu_mondo_send:
1827 mov HV_FAST_CPU_MONDO_SEND, %o5 1874 mov HV_FAST_CPU_MONDO_SEND, %o5
1828 ta HV_FAST_TRAP 1875 ta HV_FAST_TRAP
1829 retl 1876 retl
1830 nop 1877 nop
1878 .size sun4v_cpu_mondo_send, .-sun4v_cpu_mondo_send
1831 1879
1832 /* %o0: CPU ID 1880 /* %o0: CPU ID
1833 * 1881 *
@@ -1835,6 +1883,7 @@ sun4v_cpu_mondo_send:
1835 * %o0: cpu state as HV_CPU_STATE_* 1883 * %o0: cpu state as HV_CPU_STATE_*
1836 */ 1884 */
1837 .globl sun4v_cpu_state 1885 .globl sun4v_cpu_state
1886 .type sun4v_cpu_state,#function
1838sun4v_cpu_state: 1887sun4v_cpu_state:
1839 mov HV_FAST_CPU_STATE, %o5 1888 mov HV_FAST_CPU_STATE, %o5
1840 ta HV_FAST_TRAP 1889 ta HV_FAST_TRAP
@@ -1843,6 +1892,37 @@ sun4v_cpu_state:
1843 mov %o1, %o0 1892 mov %o1, %o0
18441: retl 18931: retl
1845 nop 1894 nop
1895 .size sun4v_cpu_state, .-sun4v_cpu_state
1896
1897 /* %o0: virtual address
1898 * %o1: must be zero
1899 * %o2: TTE
1900 * %o3: HV_MMU_* flags
1901 *
1902 * returns %o0: status
1903 */
1904 .globl sun4v_mmu_map_perm_addr
1905 .type sun4v_mmu_map_perm_addr,#function
1906sun4v_mmu_map_perm_addr:
1907 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
1908 ta HV_FAST_TRAP
1909 retl
1910 nop
1911 .size sun4v_mmu_map_perm_addr, .-sun4v_mmu_map_perm_addr
1912
1913 /* %o0: number of TSB descriptions
1914 * %o1: TSB descriptions real address
1915 *
1916 * returns %o0: status
1917 */
1918 .globl sun4v_mmu_tsb_ctx0
1919 .type sun4v_mmu_tsb_ctx0,#function
1920sun4v_mmu_tsb_ctx0:
1921 mov HV_FAST_MMU_TSB_CTX0, %o5
1922 ta HV_FAST_TRAP
1923 retl
1924 nop
1925 .size sun4v_mmu_tsb_ctx0, .-sun4v_mmu_tsb_ctx0
1846 1926
1847 /* %o0: API group number 1927 /* %o0: API group number
1848 * %o1: pointer to unsigned long major number storage 1928 * %o1: pointer to unsigned long major number storage
@@ -1851,6 +1931,7 @@ sun4v_cpu_state:
1851 * returns %o0: status 1931 * returns %o0: status
1852 */ 1932 */
1853 .globl sun4v_get_version 1933 .globl sun4v_get_version
1934 .type sun4v_get_version,#function
1854sun4v_get_version: 1935sun4v_get_version:
1855 mov HV_CORE_GET_VER, %o5 1936 mov HV_CORE_GET_VER, %o5
1856 mov %o1, %o3 1937 mov %o1, %o3
@@ -1859,6 +1940,7 @@ sun4v_get_version:
1859 stx %o1, [%o3] 1940 stx %o1, [%o3]
1860 retl 1941 retl
1861 stx %o2, [%o4] 1942 stx %o2, [%o4]
1943 .size sun4v_get_version, .-sun4v_get_version
1862 1944
1863 /* %o0: API group number 1945 /* %o0: API group number
1864 * %o1: desired major number 1946 * %o1: desired major number
@@ -1868,18 +1950,49 @@ sun4v_get_version:
1868 * returns %o0: status 1950 * returns %o0: status
1869 */ 1951 */
1870 .globl sun4v_set_version 1952 .globl sun4v_set_version
1953 .type sun4v_set_version,#function
1871sun4v_set_version: 1954sun4v_set_version:
1872 mov HV_CORE_SET_VER, %o5 1955 mov HV_CORE_SET_VER, %o5
1873 mov %o3, %o4 1956 mov %o3, %o4
1874 ta HV_CORE_TRAP 1957 ta HV_CORE_TRAP
1875 retl 1958 retl
1876 stx %o1, [%o4] 1959 stx %o1, [%o4]
1960 .size sun4v_set_version, .-sun4v_set_version
1961
1962 /* %o0: pointer to unsigned long time
1963 *
1964 * returns %o0: status
1965 */
1966 .globl sun4v_tod_get
1967 .type sun4v_tod_get,#function
1968sun4v_tod_get:
1969 mov %o0, %o4
1970 mov HV_FAST_TOD_GET, %o5
1971 ta HV_FAST_TRAP
1972 stx %o1, [%o4]
1973 retl
1974 nop
1975 .size sun4v_tod_get, .-sun4v_tod_get
1976
1977 /* %o0: time
1978 *
1979 * returns %o0: status
1980 */
1981 .globl sun4v_tod_set
1982 .type sun4v_tod_set,#function
1983sun4v_tod_set:
1984 mov HV_FAST_TOD_SET, %o5
1985 ta HV_FAST_TRAP
1986 retl
1987 nop
1988 .size sun4v_tod_set, .-sun4v_tod_set
1877 1989
1878 /* %o0: pointer to unsigned long status 1990 /* %o0: pointer to unsigned long status
1879 * 1991 *
1880 * returns %o0: signed character 1992 * returns %o0: signed character
1881 */ 1993 */
1882 .globl sun4v_con_getchar 1994 .globl sun4v_con_getchar
1995 .type sun4v_con_getchar,#function
1883sun4v_con_getchar: 1996sun4v_con_getchar:
1884 mov %o0, %o4 1997 mov %o0, %o4
1885 mov HV_FAST_CONS_GETCHAR, %o5 1998 mov HV_FAST_CONS_GETCHAR, %o5
@@ -1889,17 +2002,20 @@ sun4v_con_getchar:
1889 stx %o0, [%o4] 2002 stx %o0, [%o4]
1890 retl 2003 retl
1891 sra %o1, 0, %o0 2004 sra %o1, 0, %o0
2005 .size sun4v_con_getchar, .-sun4v_con_getchar
1892 2006
1893 /* %o0: signed long character 2007 /* %o0: signed long character
1894 * 2008 *
1895 * returns %o0: status 2009 * returns %o0: status
1896 */ 2010 */
1897 .globl sun4v_con_putchar 2011 .globl sun4v_con_putchar
2012 .type sun4v_con_putchar,#function
1898sun4v_con_putchar: 2013sun4v_con_putchar:
1899 mov HV_FAST_CONS_PUTCHAR, %o5 2014 mov HV_FAST_CONS_PUTCHAR, %o5
1900 ta HV_FAST_TRAP 2015 ta HV_FAST_TRAP
1901 retl 2016 retl
1902 sra %o0, 0, %o0 2017 sra %o0, 0, %o0
2018 .size sun4v_con_putchar, .-sun4v_con_putchar
1903 2019
1904 /* %o0: buffer real address 2020 /* %o0: buffer real address
1905 * %o1: buffer size 2021 * %o1: buffer size
@@ -1908,6 +2024,7 @@ sun4v_con_putchar:
1908 * returns %o0: status 2024 * returns %o0: status
1909 */ 2025 */
1910 .globl sun4v_con_read 2026 .globl sun4v_con_read
2027 .type sun4v_con_read,#function
1911sun4v_con_read: 2028sun4v_con_read:
1912 mov %o2, %o4 2029 mov %o2, %o4
1913 mov HV_FAST_CONS_READ, %o5 2030 mov HV_FAST_CONS_READ, %o5
@@ -1922,6 +2039,7 @@ sun4v_con_read:
1922 stx %o1, [%o4] 2039 stx %o1, [%o4]
19231: retl 20401: retl
1924 nop 2041 nop
2042 .size sun4v_con_read, .-sun4v_con_read
1925 2043
1926 /* %o0: buffer real address 2044 /* %o0: buffer real address
1927 * %o1: buffer size 2045 * %o1: buffer size
@@ -1930,6 +2048,7 @@ sun4v_con_read:
1930 * returns %o0: status 2048 * returns %o0: status
1931 */ 2049 */
1932 .globl sun4v_con_write 2050 .globl sun4v_con_write
2051 .type sun4v_con_write,#function
1933sun4v_con_write: 2052sun4v_con_write:
1934 mov %o2, %o4 2053 mov %o2, %o4
1935 mov HV_FAST_CONS_WRITE, %o5 2054 mov HV_FAST_CONS_WRITE, %o5
@@ -1937,3 +2056,517 @@ sun4v_con_write:
1937 stx %o1, [%o4] 2056 stx %o1, [%o4]
1938 retl 2057 retl
1939 nop 2058 nop
2059 .size sun4v_con_write, .-sun4v_con_write
2060
2061 /* %o0: soft state
2062 * %o1: address of description string
2063 *
2064 * returns %o0: status
2065 */
2066 .globl sun4v_mach_set_soft_state
2067 .type sun4v_mach_set_soft_state,#function
2068sun4v_mach_set_soft_state:
2069 mov HV_FAST_MACH_SET_SOFT_STATE, %o5
2070 ta HV_FAST_TRAP
2071 retl
2072 nop
2073 .size sun4v_mach_set_soft_state, .-sun4v_mach_set_soft_state
2074
2075 /* %o0: exit code
2076 *
2077 * Does not return.
2078 */
2079 .globl sun4v_mach_exit
2080 .type sun4v_mach_exit,#function
2081sun4v_mach_exit:
2082 mov HV_FAST_MACH_EXIT, %o5
2083 ta HV_FAST_TRAP
2084 retl
2085 nop
2086 .size sun4v_mach_exit, .-sun4v_mach_exit
2087
2088 /* %o0: buffer real address
2089 * %o1: buffer length
2090 * %o2: pointer to unsigned long real_buf_len
2091 *
2092 * returns %o0: status
2093 */
2094 .globl sun4v_mach_desc
2095 .type sun4v_mach_desc,#function
2096sun4v_mach_desc:
2097 mov %o2, %o4
2098 mov HV_FAST_MACH_DESC, %o5
2099 ta HV_FAST_TRAP
2100 stx %o1, [%o4]
2101 retl
2102 nop
2103 .size sun4v_mach_desc, .-sun4v_mach_desc
2104
2105 /* %o0: new timeout in milliseconds
2106 * %o1: pointer to unsigned long orig_timeout
2107 *
2108 * returns %o0: status
2109 */
2110 .globl sun4v_mach_set_watchdog
2111 .type sun4v_mach_set_watchdog,#function
2112sun4v_mach_set_watchdog:
2113 mov %o1, %o4
2114 mov HV_FAST_MACH_SET_WATCHDOG, %o5
2115 ta HV_FAST_TRAP
2116 stx %o1, [%o4]
2117 retl
2118 nop
2119 .size sun4v_mach_set_watchdog, .-sun4v_mach_set_watchdog
2120
2121 /* No inputs and does not return. */
2122 .globl sun4v_mach_sir
2123 .type sun4v_mach_sir,#function
2124sun4v_mach_sir:
2125 mov %o1, %o4
2126 mov HV_FAST_MACH_SIR, %o5
2127 ta HV_FAST_TRAP
2128 stx %o1, [%o4]
2129 retl
2130 nop
2131 .size sun4v_mach_sir, .-sun4v_mach_sir
2132
2133 /* %o0: channel
2134 * %o1: ra
2135 * %o2: num_entries
2136 *
2137 * returns %o0: status
2138 */
2139 .globl sun4v_ldc_tx_qconf
2140 .type sun4v_ldc_tx_qconf,#function
2141sun4v_ldc_tx_qconf:
2142 mov HV_FAST_LDC_TX_QCONF, %o5
2143 ta HV_FAST_TRAP
2144 retl
2145 nop
2146 .size sun4v_ldc_tx_qconf, .-sun4v_ldc_tx_qconf
2147
2148 /* %o0: channel
2149 * %o1: pointer to unsigned long ra
2150 * %o2: pointer to unsigned long num_entries
2151 *
2152 * returns %o0: status
2153 */
2154 .globl sun4v_ldc_tx_qinfo
2155 .type sun4v_ldc_tx_qinfo,#function
2156sun4v_ldc_tx_qinfo:
2157 mov %o1, %g1
2158 mov %o2, %g2
2159 mov HV_FAST_LDC_TX_QINFO, %o5
2160 ta HV_FAST_TRAP
2161 stx %o1, [%g1]
2162 stx %o2, [%g2]
2163 retl
2164 nop
2165 .size sun4v_ldc_tx_qinfo, .-sun4v_ldc_tx_qinfo
2166
2167 /* %o0: channel
2168 * %o1: pointer to unsigned long head_off
2169 * %o2: pointer to unsigned long tail_off
2170 * %o2: pointer to unsigned long chan_state
2171 *
2172 * returns %o0: status
2173 */
2174 .globl sun4v_ldc_tx_get_state
2175 .type sun4v_ldc_tx_get_state,#function
2176sun4v_ldc_tx_get_state:
2177 mov %o1, %g1
2178 mov %o2, %g2
2179 mov %o3, %g3
2180 mov HV_FAST_LDC_TX_GET_STATE, %o5
2181 ta HV_FAST_TRAP
2182 stx %o1, [%g1]
2183 stx %o2, [%g2]
2184 stx %o3, [%g3]
2185 retl
2186 nop
2187 .size sun4v_ldc_tx_get_state, .-sun4v_ldc_tx_get_state
2188
2189 /* %o0: channel
2190 * %o1: tail_off
2191 *
2192 * returns %o0: status
2193 */
2194 .globl sun4v_ldc_tx_set_qtail
2195 .type sun4v_ldc_tx_set_qtail,#function
2196sun4v_ldc_tx_set_qtail:
2197 mov HV_FAST_LDC_TX_SET_QTAIL, %o5
2198 ta HV_FAST_TRAP
2199 retl
2200 nop
2201 .size sun4v_ldc_tx_set_qtail, .-sun4v_ldc_tx_set_qtail
2202
2203 /* %o0: channel
2204 * %o1: ra
2205 * %o2: num_entries
2206 *
2207 * returns %o0: status
2208 */
2209 .globl sun4v_ldc_rx_qconf
2210 .type sun4v_ldc_rx_qconf,#function
2211sun4v_ldc_rx_qconf:
2212 mov HV_FAST_LDC_RX_QCONF, %o5
2213 ta HV_FAST_TRAP
2214 retl
2215 nop
2216 .size sun4v_ldc_rx_qconf, .-sun4v_ldc_rx_qconf
2217
2218 /* %o0: channel
2219 * %o1: pointer to unsigned long ra
2220 * %o2: pointer to unsigned long num_entries
2221 *
2222 * returns %o0: status
2223 */
2224 .globl sun4v_ldc_rx_qinfo
2225 .type sun4v_ldc_rx_qinfo,#function
2226sun4v_ldc_rx_qinfo:
2227 mov %o1, %g1
2228 mov %o2, %g2
2229 mov HV_FAST_LDC_RX_QINFO, %o5
2230 ta HV_FAST_TRAP
2231 stx %o1, [%g1]
2232 stx %o2, [%g2]
2233 retl
2234 nop
2235 .size sun4v_ldc_rx_qinfo, .-sun4v_ldc_rx_qinfo
2236
2237 /* %o0: channel
2238 * %o1: pointer to unsigned long head_off
2239 * %o2: pointer to unsigned long tail_off
2240 * %o2: pointer to unsigned long chan_state
2241 *
2242 * returns %o0: status
2243 */
2244 .globl sun4v_ldc_rx_get_state
2245 .type sun4v_ldc_rx_get_state,#function
2246sun4v_ldc_rx_get_state:
2247 mov %o1, %g1
2248 mov %o2, %g2
2249 mov %o3, %g3
2250 mov HV_FAST_LDC_RX_GET_STATE, %o5
2251 ta HV_FAST_TRAP
2252 stx %o1, [%g1]
2253 stx %o2, [%g2]
2254 stx %o3, [%g3]
2255 retl
2256 nop
2257 .size sun4v_ldc_rx_get_state, .-sun4v_ldc_rx_get_state
2258
2259 /* %o0: channel
2260 * %o1: head_off
2261 *
2262 * returns %o0: status
2263 */
2264 .globl sun4v_ldc_rx_set_qhead
2265 .type sun4v_ldc_rx_set_qhead,#function
2266sun4v_ldc_rx_set_qhead:
2267 mov HV_FAST_LDC_RX_SET_QHEAD, %o5
2268 ta HV_FAST_TRAP
2269 retl
2270 nop
2271 .size sun4v_ldc_rx_set_qhead, .-sun4v_ldc_rx_set_qhead
2272
2273 /* %o0: channel
2274 * %o1: ra
2275 * %o2: num_entries
2276 *
2277 * returns %o0: status
2278 */
2279 .globl sun4v_ldc_set_map_table
2280 .type sun4v_ldc_set_map_table,#function
2281sun4v_ldc_set_map_table:
2282 mov HV_FAST_LDC_SET_MAP_TABLE, %o5
2283 ta HV_FAST_TRAP
2284 retl
2285 nop
2286 .size sun4v_ldc_set_map_table, .-sun4v_ldc_set_map_table
2287
2288 /* %o0: channel
2289 * %o1: pointer to unsigned long ra
2290 * %o2: pointer to unsigned long num_entries
2291 *
2292 * returns %o0: status
2293 */
2294 .globl sun4v_ldc_get_map_table
2295 .type sun4v_ldc_get_map_table,#function
2296sun4v_ldc_get_map_table:
2297 mov %o1, %g1
2298 mov %o2, %g2
2299 mov HV_FAST_LDC_GET_MAP_TABLE, %o5
2300 ta HV_FAST_TRAP
2301 stx %o1, [%g1]
2302 stx %o2, [%g2]
2303 retl
2304 nop
2305 .size sun4v_ldc_get_map_table, .-sun4v_ldc_get_map_table
2306
2307 /* %o0: channel
2308 * %o1: dir_code
2309 * %o2: tgt_raddr
2310 * %o3: lcl_raddr
2311 * %o4: len
2312 * %o5: pointer to unsigned long actual_len
2313 *
2314 * returns %o0: status
2315 */
2316 .globl sun4v_ldc_copy
2317 .type sun4v_ldc_copy,#function
2318sun4v_ldc_copy:
2319 mov %o5, %g1
2320 mov HV_FAST_LDC_COPY, %o5
2321 ta HV_FAST_TRAP
2322 stx %o1, [%g1]
2323 retl
2324 nop
2325 .size sun4v_ldc_copy, .-sun4v_ldc_copy
2326
2327 /* %o0: channel
2328 * %o1: cookie
2329 * %o2: pointer to unsigned long ra
2330 * %o3: pointer to unsigned long perm
2331 *
2332 * returns %o0: status
2333 */
2334 .globl sun4v_ldc_mapin
2335 .type sun4v_ldc_mapin,#function
2336sun4v_ldc_mapin:
2337 mov %o2, %g1
2338 mov %o3, %g2
2339 mov HV_FAST_LDC_MAPIN, %o5
2340 ta HV_FAST_TRAP
2341 stx %o1, [%g1]
2342 stx %o2, [%g2]
2343 retl
2344 nop
2345 .size sun4v_ldc_mapin, .-sun4v_ldc_mapin
2346
2347 /* %o0: ra
2348 *
2349 * returns %o0: status
2350 */
2351 .globl sun4v_ldc_unmap
2352 .type sun4v_ldc_unmap,#function
2353sun4v_ldc_unmap:
2354 mov HV_FAST_LDC_UNMAP, %o5
2355 ta HV_FAST_TRAP
2356 retl
2357 nop
2358 .size sun4v_ldc_unmap, .-sun4v_ldc_unmap
2359
2360 /* %o0: cookie
2361 * %o1: mte_cookie
2362 *
2363 * returns %o0: status
2364 */
2365 .globl sun4v_ldc_revoke
2366 .type sun4v_ldc_revoke,#function
2367sun4v_ldc_revoke:
2368 mov HV_FAST_LDC_REVOKE, %o5
2369 ta HV_FAST_TRAP
2370 retl
2371 nop
2372 .size sun4v_ldc_revoke, .-sun4v_ldc_revoke
2373
2374 /* %o0: device handle
2375 * %o1: device INO
2376 * %o2: pointer to unsigned long cookie
2377 *
2378 * returns %o0: status
2379 */
2380 .globl sun4v_vintr_get_cookie
2381 .type sun4v_vintr_get_cookie,#function
2382sun4v_vintr_get_cookie:
2383 mov %o2, %g1
2384 mov HV_FAST_VINTR_GET_COOKIE, %o5
2385 ta HV_FAST_TRAP
2386 stx %o1, [%g1]
2387 retl
2388 nop
2389 .size sun4v_vintr_get_cookie, .-sun4v_vintr_get_cookie
2390
2391 /* %o0: device handle
2392 * %o1: device INO
2393 * %o2: cookie
2394 *
2395 * returns %o0: status
2396 */
2397 .globl sun4v_vintr_set_cookie
2398 .type sun4v_vintr_set_cookie,#function
2399sun4v_vintr_set_cookie:
2400 mov HV_FAST_VINTR_SET_COOKIE, %o5
2401 ta HV_FAST_TRAP
2402 retl
2403 nop
2404 .size sun4v_vintr_set_cookie, .-sun4v_vintr_set_cookie
2405
2406 /* %o0: device handle
2407 * %o1: device INO
2408 * %o2: pointer to unsigned long valid_state
2409 *
2410 * returns %o0: status
2411 */
2412 .globl sun4v_vintr_get_valid
2413 .type sun4v_vintr_get_valid,#function
2414sun4v_vintr_get_valid:
2415 mov %o2, %g1
2416 mov HV_FAST_VINTR_GET_VALID, %o5
2417 ta HV_FAST_TRAP
2418 stx %o1, [%g1]
2419 retl
2420 nop
2421 .size sun4v_vintr_get_valid, .-sun4v_vintr_get_valid
2422
2423 /* %o0: device handle
2424 * %o1: device INO
2425 * %o2: valid_state
2426 *
2427 * returns %o0: status
2428 */
2429 .globl sun4v_vintr_set_valid
2430 .type sun4v_vintr_set_valid,#function
2431sun4v_vintr_set_valid:
2432 mov HV_FAST_VINTR_SET_VALID, %o5
2433 ta HV_FAST_TRAP
2434 retl
2435 nop
2436 .size sun4v_vintr_set_valid, .-sun4v_vintr_set_valid
2437
2438 /* %o0: device handle
2439 * %o1: device INO
2440 * %o2: pointer to unsigned long state
2441 *
2442 * returns %o0: status
2443 */
2444 .globl sun4v_vintr_get_state
2445 .type sun4v_vintr_get_state,#function
2446sun4v_vintr_get_state:
2447 mov %o2, %g1
2448 mov HV_FAST_VINTR_GET_STATE, %o5
2449 ta HV_FAST_TRAP
2450 stx %o1, [%g1]
2451 retl
2452 nop
2453 .size sun4v_vintr_get_state, .-sun4v_vintr_get_state
2454
2455 /* %o0: device handle
2456 * %o1: device INO
2457 * %o2: state
2458 *
2459 * returns %o0: status
2460 */
2461 .globl sun4v_vintr_set_state
2462 .type sun4v_vintr_set_state,#function
2463sun4v_vintr_set_state:
2464 mov HV_FAST_VINTR_SET_STATE, %o5
2465 ta HV_FAST_TRAP
2466 retl
2467 nop
2468 .size sun4v_vintr_set_state, .-sun4v_vintr_set_state
2469
2470 /* %o0: device handle
2471 * %o1: device INO
2472 * %o2: pointer to unsigned long cpuid
2473 *
2474 * returns %o0: status
2475 */
2476 .globl sun4v_vintr_get_target
2477 .type sun4v_vintr_get_target,#function
2478sun4v_vintr_get_target:
2479 mov %o2, %g1
2480 mov HV_FAST_VINTR_GET_TARGET, %o5
2481 ta HV_FAST_TRAP
2482 stx %o1, [%g1]
2483 retl
2484 nop
2485 .size sun4v_vintr_get_target, .-sun4v_vintr_get_target
2486
2487 /* %o0: device handle
2488 * %o1: device INO
2489 * %o2: cpuid
2490 *
2491 * returns %o0: status
2492 */
2493 .globl sun4v_vintr_set_target
2494 .type sun4v_vintr_set_target,#function
2495sun4v_vintr_set_target:
2496 mov HV_FAST_VINTR_SET_TARGET, %o5
2497 ta HV_FAST_TRAP
2498 retl
2499 nop
2500 .size sun4v_vintr_set_target, .-sun4v_vintr_set_target
2501
2502 /* %o0: NCS sub-function
2503 * %o1: sub-function arg real-address
2504 * %o2: sub-function arg size
2505 *
2506 * returns %o0: status
2507 */
2508 .globl sun4v_ncs_request
2509 .type sun4v_ncs_request,#function
2510sun4v_ncs_request:
2511 mov HV_FAST_NCS_REQUEST, %o5
2512 ta HV_FAST_TRAP
2513 retl
2514 nop
2515 .size sun4v_ncs_request, .-sun4v_ncs_request
2516
2517 .globl sun4v_scv_send
2518 .type sun4v_scv_send,#function
2519sun4v_scv_send:
2520 save %sp, -192, %sp
2521 mov %i0, %o0
2522 mov %i1, %o1
2523 mov %i2, %o2
2524 mov HV_FAST_SVC_SEND, %o5
2525 ta HV_FAST_TRAP
2526 stx %o1, [%i3]
2527 ret
2528 restore
2529 .size sun4v_scv_send, .-sun4v_scv_send
2530
2531 .globl sun4v_scv_recv
2532 .type sun4v_scv_recv,#function
2533sun4v_scv_recv:
2534 save %sp, -192, %sp
2535 mov %i0, %o0
2536 mov %i1, %o1
2537 mov %i2, %o2
2538 mov HV_FAST_SVC_RECV, %o5
2539 ta HV_FAST_TRAP
2540 stx %o1, [%i3]
2541 ret
2542 restore
2543 .size sun4v_scv_recv, .-sun4v_scv_recv
2544
2545 .globl sun4v_scv_getstatus
2546 .type sun4v_scv_getstatus,#function
2547sun4v_scv_getstatus:
2548 mov HV_FAST_SVC_GETSTATUS, %o5
2549 mov %o1, %o4
2550 ta HV_FAST_TRAP
2551 stx %o1, [%o4]
2552 retl
2553 nop
2554 .size sun4v_scv_getstatus, .-sun4v_scv_getstatus
2555
2556 .globl sun4v_scv_setstatus
2557 .type sun4v_scv_setstatus,#function
2558sun4v_scv_setstatus:
2559 mov HV_FAST_SVC_SETSTATUS, %o5
2560 ta HV_FAST_TRAP
2561 retl
2562 nop
2563 .size sun4v_scv_setstatus, .-sun4v_scv_setstatus
2564
2565 .globl sun4v_scv_clrstatus
2566 .type sun4v_scv_clrstatus,#function
2567sun4v_scv_clrstatus:
2568 mov HV_FAST_SVC_CLRSTATUS, %o5
2569 ta HV_FAST_TRAP
2570 retl
2571 nop
2572 .size sun4v_scv_clrstatus, .-sun4v_scv_clrstatus
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index baea10a98196..77259526cb15 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -523,7 +523,7 @@ tlb_fixup_done:
523#else 523#else
524 mov 0, %o0 524 mov 0, %o0
525#endif 525#endif
526 stb %o0, [%g6 + TI_CPU] 526 sth %o0, [%g6 + TI_CPU]
527 527
528 /* Off we go.... */ 528 /* Off we go.... */
529 call start_kernel 529 call start_kernel
@@ -653,33 +653,54 @@ setup_tba:
653 restore 653 restore
654sparc64_boot_end: 654sparc64_boot_end:
655 655
656#include "ktlb.S"
657#include "tsb.S"
658#include "etrap.S" 656#include "etrap.S"
659#include "rtrap.S" 657#include "rtrap.S"
660#include "winfixup.S" 658#include "winfixup.S"
661#include "entry.S" 659#include "entry.S"
662#include "sun4v_tlb_miss.S" 660#include "sun4v_tlb_miss.S"
663#include "sun4v_ivec.S" 661#include "sun4v_ivec.S"
662#include "ktlb.S"
663#include "tsb.S"
664 664
665/* 665/*
666 * The following skip makes sure the trap table in ttable.S is aligned 666 * The following skip makes sure the trap table in ttable.S is aligned
667 * on a 32K boundary as required by the v9 specs for TBA register. 667 * on a 32K boundary as required by the v9 specs for TBA register.
668 * 668 *
669 * We align to a 32K boundary, then we have the 32K kernel TSB, 669 * We align to a 32K boundary, then we have the 32K kernel TSB,
670 * then the 32K aligned trap table. 670 * the 64K kernel 4MB TSB, and then the 32K aligned trap table.
671 */ 671 */
6721: 6721:
673 .skip 0x4000 + _start - 1b 673 .skip 0x4000 + _start - 1b
674 674
675! 0x0000000000408000
676
675 .globl swapper_tsb 677 .globl swapper_tsb
676swapper_tsb: 678swapper_tsb:
677 .skip (32 * 1024) 679 .skip (32 * 1024)
678 680
679! 0x0000000000408000 681 .globl swapper_4m_tsb
682swapper_4m_tsb:
683 .skip (64 * 1024)
684
685! 0x0000000000420000
680 686
687 /* Some care needs to be exercised if you try to move the
688 * location of the trap table relative to other things. For
689 * one thing there are br* instructions in some of the
690 * trap table entires which branch back to code in ktlb.S
691 * Those instructions can only handle a signed 16-bit
692 * displacement.
693 *
694 * There is a binutils bug (bugzilla #4558) which causes
695 * the relocation overflow checks for such instructions to
696 * not be done correctly. So bintuils will not notice the
697 * error and will instead write junk into the relocation and
698 * you'll have an unbootable kernel.
699 */
681#include "ttable.S" 700#include "ttable.S"
682 701
702! 0x0000000000428000
703
683#include "systbls.S" 704#include "systbls.S"
684 705
685 .data 706 .data
diff --git a/arch/sparc64/kernel/hvapi.c b/arch/sparc64/kernel/hvapi.c
index f03ffc829c7a..f34f5d6181ef 100644
--- a/arch/sparc64/kernel/hvapi.c
+++ b/arch/sparc64/kernel/hvapi.c
@@ -9,6 +9,7 @@
9 9
10#include <asm/hypervisor.h> 10#include <asm/hypervisor.h>
11#include <asm/oplib.h> 11#include <asm/oplib.h>
12#include <asm/sstate.h>
12 13
13/* If the hypervisor indicates that the API setting 14/* If the hypervisor indicates that the API setting
14 * calls are unsupported, by returning HV_EBADTRAP or 15 * calls are unsupported, by returning HV_EBADTRAP or
@@ -107,7 +108,7 @@ int sun4v_hvapi_register(unsigned long group, unsigned long major,
107 p->minor = actual_minor; 108 p->minor = actual_minor;
108 ret = 0; 109 ret = 0;
109 } else if (hv_ret == HV_EBADTRAP || 110 } else if (hv_ret == HV_EBADTRAP ||
110 HV_ENOTSUPPORTED) { 111 hv_ret == HV_ENOTSUPPORTED) {
111 if (p->flags & FLAG_PRE_API) { 112 if (p->flags & FLAG_PRE_API) {
112 if (major == 1) { 113 if (major == 1) {
113 p->major = 1; 114 p->major = 1;
@@ -179,6 +180,8 @@ void __init sun4v_hvapi_init(void)
179 if (sun4v_hvapi_register(group, major, &minor)) 180 if (sun4v_hvapi_register(group, major, &minor))
180 goto bad; 181 goto bad;
181 182
183 sun4v_sstate_init();
184
182 return; 185 return;
183 186
184bad: 187bad:
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index 3edc18e1b818..a36f8dd0c021 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -171,8 +171,6 @@ skip:
171 return 0; 171 return 0;
172} 172}
173 173
174extern unsigned long real_hard_smp_processor_id(void);
175
176static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid) 174static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid)
177{ 175{
178 unsigned int tid; 176 unsigned int tid;
@@ -694,9 +692,20 @@ void init_irqwork_curcpu(void)
694 trap_block[cpu].irq_worklist = 0; 692 trap_block[cpu].irq_worklist = 0;
695} 693}
696 694
697static void __cpuinit register_one_mondo(unsigned long paddr, unsigned long type) 695/* Please be very careful with register_one_mondo() and
696 * sun4v_register_mondo_queues().
697 *
698 * On SMP this gets invoked from the CPU trampoline before
699 * the cpu has fully taken over the trap table from OBP,
700 * and it's kernel stack + %g6 thread register state is
701 * not fully cooked yet.
702 *
703 * Therefore you cannot make any OBP calls, not even prom_printf,
704 * from these two routines.
705 */
706static void __cpuinit register_one_mondo(unsigned long paddr, unsigned long type, unsigned long qmask)
698{ 707{
699 unsigned long num_entries = 128; 708 unsigned long num_entries = (qmask + 1) / 64;
700 unsigned long status; 709 unsigned long status;
701 710
702 status = sun4v_cpu_qconf(type, paddr, num_entries); 711 status = sun4v_cpu_qconf(type, paddr, num_entries);
@@ -711,44 +720,58 @@ static void __cpuinit sun4v_register_mondo_queues(int this_cpu)
711{ 720{
712 struct trap_per_cpu *tb = &trap_block[this_cpu]; 721 struct trap_per_cpu *tb = &trap_block[this_cpu];
713 722
714 register_one_mondo(tb->cpu_mondo_pa, HV_CPU_QUEUE_CPU_MONDO); 723 register_one_mondo(tb->cpu_mondo_pa, HV_CPU_QUEUE_CPU_MONDO,
715 register_one_mondo(tb->dev_mondo_pa, HV_CPU_QUEUE_DEVICE_MONDO); 724 tb->cpu_mondo_qmask);
716 register_one_mondo(tb->resum_mondo_pa, HV_CPU_QUEUE_RES_ERROR); 725 register_one_mondo(tb->dev_mondo_pa, HV_CPU_QUEUE_DEVICE_MONDO,
717 register_one_mondo(tb->nonresum_mondo_pa, HV_CPU_QUEUE_NONRES_ERROR); 726 tb->dev_mondo_qmask);
727 register_one_mondo(tb->resum_mondo_pa, HV_CPU_QUEUE_RES_ERROR,
728 tb->resum_qmask);
729 register_one_mondo(tb->nonresum_mondo_pa, HV_CPU_QUEUE_NONRES_ERROR,
730 tb->nonresum_qmask);
718} 731}
719 732
720static void __cpuinit alloc_one_mondo(unsigned long *pa_ptr, int use_bootmem) 733static void __cpuinit alloc_one_mondo(unsigned long *pa_ptr, unsigned long qmask, int use_bootmem)
721{ 734{
722 void *page; 735 unsigned long size = PAGE_ALIGN(qmask + 1);
736 unsigned long order = get_order(size);
737 void *p = NULL;
723 738
724 if (use_bootmem) 739 if (use_bootmem) {
725 page = alloc_bootmem_low_pages(PAGE_SIZE); 740 p = __alloc_bootmem_low(size, size, 0);
726 else 741 } else {
727 page = (void *) get_zeroed_page(GFP_ATOMIC); 742 struct page *page = alloc_pages(GFP_ATOMIC | __GFP_ZERO, order);
743 if (page)
744 p = page_address(page);
745 }
728 746
729 if (!page) { 747 if (!p) {
730 prom_printf("SUN4V: Error, cannot allocate mondo queue.\n"); 748 prom_printf("SUN4V: Error, cannot allocate mondo queue.\n");
731 prom_halt(); 749 prom_halt();
732 } 750 }
733 751
734 *pa_ptr = __pa(page); 752 *pa_ptr = __pa(p);
735} 753}
736 754
737static void __cpuinit alloc_one_kbuf(unsigned long *pa_ptr, int use_bootmem) 755static void __cpuinit alloc_one_kbuf(unsigned long *pa_ptr, unsigned long qmask, int use_bootmem)
738{ 756{
739 void *page; 757 unsigned long size = PAGE_ALIGN(qmask + 1);
758 unsigned long order = get_order(size);
759 void *p = NULL;
740 760
741 if (use_bootmem) 761 if (use_bootmem) {
742 page = alloc_bootmem_low_pages(PAGE_SIZE); 762 p = __alloc_bootmem_low(size, size, 0);
743 else 763 } else {
744 page = (void *) get_zeroed_page(GFP_ATOMIC); 764 struct page *page = alloc_pages(GFP_ATOMIC | __GFP_ZERO, order);
765 if (page)
766 p = page_address(page);
767 }
745 768
746 if (!page) { 769 if (!p) {
747 prom_printf("SUN4V: Error, cannot allocate kbuf page.\n"); 770 prom_printf("SUN4V: Error, cannot allocate kbuf page.\n");
748 prom_halt(); 771 prom_halt();
749 } 772 }
750 773
751 *pa_ptr = __pa(page); 774 *pa_ptr = __pa(p);
752} 775}
753 776
754static void __cpuinit init_cpu_send_mondo_info(struct trap_per_cpu *tb, int use_bootmem) 777static void __cpuinit init_cpu_send_mondo_info(struct trap_per_cpu *tb, int use_bootmem)
@@ -779,12 +802,12 @@ void __cpuinit sun4v_init_mondo_queues(int use_bootmem, int cpu, int alloc, int
779 struct trap_per_cpu *tb = &trap_block[cpu]; 802 struct trap_per_cpu *tb = &trap_block[cpu];
780 803
781 if (alloc) { 804 if (alloc) {
782 alloc_one_mondo(&tb->cpu_mondo_pa, use_bootmem); 805 alloc_one_mondo(&tb->cpu_mondo_pa, tb->cpu_mondo_qmask, use_bootmem);
783 alloc_one_mondo(&tb->dev_mondo_pa, use_bootmem); 806 alloc_one_mondo(&tb->dev_mondo_pa, tb->dev_mondo_qmask, use_bootmem);
784 alloc_one_mondo(&tb->resum_mondo_pa, use_bootmem); 807 alloc_one_mondo(&tb->resum_mondo_pa, tb->resum_qmask, use_bootmem);
785 alloc_one_kbuf(&tb->resum_kernel_buf_pa, use_bootmem); 808 alloc_one_kbuf(&tb->resum_kernel_buf_pa, tb->resum_qmask, use_bootmem);
786 alloc_one_mondo(&tb->nonresum_mondo_pa, use_bootmem); 809 alloc_one_mondo(&tb->nonresum_mondo_pa, tb->nonresum_qmask, use_bootmem);
787 alloc_one_kbuf(&tb->nonresum_kernel_buf_pa, use_bootmem); 810 alloc_one_kbuf(&tb->nonresum_kernel_buf_pa, tb->nonresum_qmask, use_bootmem);
788 811
789 init_cpu_send_mondo_info(tb, use_bootmem); 812 init_cpu_send_mondo_info(tb, use_bootmem);
790 } 813 }
diff --git a/arch/sparc64/kernel/itlb_miss.S b/arch/sparc64/kernel/itlb_miss.S
index ad46e2024f4b..5a8377b54955 100644
--- a/arch/sparc64/kernel/itlb_miss.S
+++ b/arch/sparc64/kernel/itlb_miss.S
@@ -11,12 +11,12 @@
11/* ITLB ** ICACHE line 2: TSB compare and TLB load */ 11/* ITLB ** ICACHE line 2: TSB compare and TLB load */
12 bne,pn %xcc, tsb_miss_itlb ! Miss 12 bne,pn %xcc, tsb_miss_itlb ! Miss
13 mov FAULT_CODE_ITLB, %g3 13 mov FAULT_CODE_ITLB, %g3
14 andcc %g5, _PAGE_EXEC_4U, %g0 ! Executable? 14 sethi %hi(_PAGE_EXEC_4U), %g4
15 andcc %g5, %g4, %g0 ! Executable?
15 be,pn %xcc, tsb_do_fault 16 be,pn %xcc, tsb_do_fault
16 nop ! Delay slot, fill me 17 nop ! Delay slot, fill me
17 stxa %g5, [%g0] ASI_ITLB_DATA_IN ! Load TLB 18 stxa %g5, [%g0] ASI_ITLB_DATA_IN ! Load TLB
18 retry ! Trap done 19 retry ! Trap done
19 nop
20 20
21/* ITLB ** ICACHE line 3: */ 21/* ITLB ** ICACHE line 3: */
22 nop 22 nop
diff --git a/arch/sparc64/kernel/mdesc.c b/arch/sparc64/kernel/mdesc.c
new file mode 100644
index 000000000000..9246c2cf9574
--- /dev/null
+++ b/arch/sparc64/kernel/mdesc.c
@@ -0,0 +1,619 @@
1/* mdesc.c: Sun4V machine description handling.
2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */
5#include <linux/kernel.h>
6#include <linux/types.h>
7#include <linux/bootmem.h>
8#include <linux/log2.h>
9
10#include <asm/hypervisor.h>
11#include <asm/mdesc.h>
12#include <asm/prom.h>
13#include <asm/oplib.h>
14#include <asm/smp.h>
15
16/* Unlike the OBP device tree, the machine description is a full-on
17 * DAG. An arbitrary number of ARCs are possible from one
18 * node to other nodes and thus we can't use the OBP device_node
19 * data structure to represent these nodes inside of the kernel.
20 *
21 * Actually, it isn't even a DAG, because there are back pointers
22 * which create cycles in the graph.
23 *
24 * mdesc_hdr and mdesc_elem describe the layout of the data structure
25 * we get from the Hypervisor.
26 */
27struct mdesc_hdr {
28 u32 version; /* Transport version */
29 u32 node_sz; /* node block size */
30 u32 name_sz; /* name block size */
31 u32 data_sz; /* data block size */
32};
33
34struct mdesc_elem {
35 u8 tag;
36#define MD_LIST_END 0x00
37#define MD_NODE 0x4e
38#define MD_NODE_END 0x45
39#define MD_NOOP 0x20
40#define MD_PROP_ARC 0x61
41#define MD_PROP_VAL 0x76
42#define MD_PROP_STR 0x73
43#define MD_PROP_DATA 0x64
44 u8 name_len;
45 u16 resv;
46 u32 name_offset;
47 union {
48 struct {
49 u32 data_len;
50 u32 data_offset;
51 } data;
52 u64 val;
53 } d;
54};
55
56static struct mdesc_hdr *main_mdesc;
57static struct mdesc_node *allnodes;
58
59static struct mdesc_node *allnodes_tail;
60static unsigned int unique_id;
61
62static struct mdesc_node **mdesc_hash;
63static unsigned int mdesc_hash_size;
64
65static inline unsigned int node_hashfn(u64 node)
66{
67 return ((unsigned int) (node ^ (node >> 8) ^ (node >> 16)))
68 & (mdesc_hash_size - 1);
69}
70
71static inline void hash_node(struct mdesc_node *mp)
72{
73 struct mdesc_node **head = &mdesc_hash[node_hashfn(mp->node)];
74
75 mp->hash_next = *head;
76 *head = mp;
77
78 if (allnodes_tail) {
79 allnodes_tail->allnodes_next = mp;
80 allnodes_tail = mp;
81 } else {
82 allnodes = allnodes_tail = mp;
83 }
84}
85
86static struct mdesc_node *find_node(u64 node)
87{
88 struct mdesc_node *mp = mdesc_hash[node_hashfn(node)];
89
90 while (mp) {
91 if (mp->node == node)
92 return mp;
93
94 mp = mp->hash_next;
95 }
96 return NULL;
97}
98
99struct property *md_find_property(const struct mdesc_node *mp,
100 const char *name,
101 int *lenp)
102{
103 struct property *pp;
104
105 for (pp = mp->properties; pp != 0; pp = pp->next) {
106 if (strcasecmp(pp->name, name) == 0) {
107 if (lenp)
108 *lenp = pp->length;
109 break;
110 }
111 }
112 return pp;
113}
114EXPORT_SYMBOL(md_find_property);
115
116/*
117 * Find a property with a given name for a given node
118 * and return the value.
119 */
120const void *md_get_property(const struct mdesc_node *mp, const char *name,
121 int *lenp)
122{
123 struct property *pp = md_find_property(mp, name, lenp);
124 return pp ? pp->value : NULL;
125}
126EXPORT_SYMBOL(md_get_property);
127
128struct mdesc_node *md_find_node_by_name(struct mdesc_node *from,
129 const char *name)
130{
131 struct mdesc_node *mp;
132
133 mp = from ? from->allnodes_next : allnodes;
134 for (; mp != NULL; mp = mp->allnodes_next) {
135 if (strcmp(mp->name, name) == 0)
136 break;
137 }
138 return mp;
139}
140EXPORT_SYMBOL(md_find_node_by_name);
141
142static unsigned int mdesc_early_allocated;
143
144static void * __init mdesc_early_alloc(unsigned long size)
145{
146 void *ret;
147
148 ret = __alloc_bootmem(size, SMP_CACHE_BYTES, 0UL);
149 if (ret == NULL) {
150 prom_printf("MDESC: alloc of %lu bytes failed.\n", size);
151 prom_halt();
152 }
153
154 memset(ret, 0, size);
155
156 mdesc_early_allocated += size;
157
158 return ret;
159}
160
161static unsigned int __init count_arcs(struct mdesc_elem *ep)
162{
163 unsigned int ret = 0;
164
165 ep++;
166 while (ep->tag != MD_NODE_END) {
167 if (ep->tag == MD_PROP_ARC)
168 ret++;
169 ep++;
170 }
171 return ret;
172}
173
174static void __init mdesc_node_alloc(u64 node, struct mdesc_elem *ep, const char *names)
175{
176 unsigned int num_arcs = count_arcs(ep);
177 struct mdesc_node *mp;
178
179 mp = mdesc_early_alloc(sizeof(*mp) +
180 (num_arcs * sizeof(struct mdesc_arc)));
181 mp->name = names + ep->name_offset;
182 mp->node = node;
183 mp->unique_id = unique_id++;
184 mp->num_arcs = num_arcs;
185
186 hash_node(mp);
187}
188
189static inline struct mdesc_elem *node_block(struct mdesc_hdr *mdesc)
190{
191 return (struct mdesc_elem *) (mdesc + 1);
192}
193
194static inline void *name_block(struct mdesc_hdr *mdesc)
195{
196 return ((void *) node_block(mdesc)) + mdesc->node_sz;
197}
198
199static inline void *data_block(struct mdesc_hdr *mdesc)
200{
201 return ((void *) name_block(mdesc)) + mdesc->name_sz;
202}
203
204/* In order to avoid recursion (the graph can be very deep) we use a
205 * two pass algorithm. First we allocate all the nodes and hash them.
206 * Then we iterate over each node, filling in the arcs and properties.
207 */
208static void __init build_all_nodes(struct mdesc_hdr *mdesc)
209{
210 struct mdesc_elem *start, *ep;
211 struct mdesc_node *mp;
212 const char *names;
213 void *data;
214 u64 last_node;
215
216 start = ep = node_block(mdesc);
217 last_node = mdesc->node_sz / 16;
218
219 names = name_block(mdesc);
220
221 while (1) {
222 u64 node = ep - start;
223
224 if (ep->tag == MD_LIST_END)
225 break;
226
227 if (ep->tag != MD_NODE) {
228 prom_printf("MDESC: Inconsistent element list.\n");
229 prom_halt();
230 }
231
232 mdesc_node_alloc(node, ep, names);
233
234 if (ep->d.val >= last_node) {
235 printk("MDESC: Warning, early break out of node scan.\n");
236 printk("MDESC: Next node [%lu] last_node [%lu].\n",
237 node, last_node);
238 break;
239 }
240
241 ep = start + ep->d.val;
242 }
243
244 data = data_block(mdesc);
245 for (mp = allnodes; mp; mp = mp->allnodes_next) {
246 struct mdesc_elem *ep = start + mp->node;
247 struct property **link = &mp->properties;
248 unsigned int this_arc = 0;
249
250 ep++;
251 while (ep->tag != MD_NODE_END) {
252 switch (ep->tag) {
253 case MD_PROP_ARC: {
254 struct mdesc_node *target;
255
256 if (this_arc >= mp->num_arcs) {
257 prom_printf("MDESC: ARC overrun [%u:%u]\n",
258 this_arc, mp->num_arcs);
259 prom_halt();
260 }
261 target = find_node(ep->d.val);
262 if (!target) {
263 printk("MDESC: Warning, arc points to "
264 "missing node, ignoring.\n");
265 break;
266 }
267 mp->arcs[this_arc].name =
268 (names + ep->name_offset);
269 mp->arcs[this_arc].arc = target;
270 this_arc++;
271 break;
272 }
273
274 case MD_PROP_VAL:
275 case MD_PROP_STR:
276 case MD_PROP_DATA: {
277 struct property *p = mdesc_early_alloc(sizeof(*p));
278
279 p->unique_id = unique_id++;
280 p->name = (char *) names + ep->name_offset;
281 if (ep->tag == MD_PROP_VAL) {
282 p->value = &ep->d.val;
283 p->length = 8;
284 } else {
285 p->value = data + ep->d.data.data_offset;
286 p->length = ep->d.data.data_len;
287 }
288 *link = p;
289 link = &p->next;
290 break;
291 }
292
293 case MD_NOOP:
294 break;
295
296 default:
297 printk("MDESC: Warning, ignoring unknown tag type %02x\n",
298 ep->tag);
299 }
300 ep++;
301 }
302 }
303}
304
305static unsigned int __init count_nodes(struct mdesc_hdr *mdesc)
306{
307 struct mdesc_elem *ep = node_block(mdesc);
308 struct mdesc_elem *end;
309 unsigned int cnt = 0;
310
311 end = ((void *)ep) + mdesc->node_sz;
312 while (ep < end) {
313 if (ep->tag == MD_NODE)
314 cnt++;
315 ep++;
316 }
317 return cnt;
318}
319
320static void __init report_platform_properties(void)
321{
322 struct mdesc_node *pn = md_find_node_by_name(NULL, "platform");
323 const char *s;
324 const u64 *v;
325
326 if (!pn) {
327 prom_printf("No platform node in machine-description.\n");
328 prom_halt();
329 }
330
331 s = md_get_property(pn, "banner-name", NULL);
332 printk("PLATFORM: banner-name [%s]\n", s);
333 s = md_get_property(pn, "name", NULL);
334 printk("PLATFORM: name [%s]\n", s);
335
336 v = md_get_property(pn, "hostid", NULL);
337 if (v)
338 printk("PLATFORM: hostid [%08lx]\n", *v);
339 v = md_get_property(pn, "serial#", NULL);
340 if (v)
341 printk("PLATFORM: serial# [%08lx]\n", *v);
342 v = md_get_property(pn, "stick-frequency", NULL);
343 printk("PLATFORM: stick-frequency [%08lx]\n", *v);
344 v = md_get_property(pn, "mac-address", NULL);
345 if (v)
346 printk("PLATFORM: mac-address [%lx]\n", *v);
347 v = md_get_property(pn, "watchdog-resolution", NULL);
348 if (v)
349 printk("PLATFORM: watchdog-resolution [%lu ms]\n", *v);
350 v = md_get_property(pn, "watchdog-max-timeout", NULL);
351 if (v)
352 printk("PLATFORM: watchdog-max-timeout [%lu ms]\n", *v);
353 v = md_get_property(pn, "max-cpus", NULL);
354 if (v)
355 printk("PLATFORM: max-cpus [%lu]\n", *v);
356}
357
358static int inline find_in_proplist(const char *list, const char *match, int len)
359{
360 while (len > 0) {
361 int l;
362
363 if (!strcmp(list, match))
364 return 1;
365 l = strlen(list) + 1;
366 list += l;
367 len -= l;
368 }
369 return 0;
370}
371
372static void __init fill_in_one_cache(cpuinfo_sparc *c, struct mdesc_node *mp)
373{
374 const u64 *level = md_get_property(mp, "level", NULL);
375 const u64 *size = md_get_property(mp, "size", NULL);
376 const u64 *line_size = md_get_property(mp, "line-size", NULL);
377 const char *type;
378 int type_len;
379
380 type = md_get_property(mp, "type", &type_len);
381
382 switch (*level) {
383 case 1:
384 if (find_in_proplist(type, "instn", type_len)) {
385 c->icache_size = *size;
386 c->icache_line_size = *line_size;
387 } else if (find_in_proplist(type, "data", type_len)) {
388 c->dcache_size = *size;
389 c->dcache_line_size = *line_size;
390 }
391 break;
392
393 case 2:
394 c->ecache_size = *size;
395 c->ecache_line_size = *line_size;
396 break;
397
398 default:
399 break;
400 }
401
402 if (*level == 1) {
403 unsigned int i;
404
405 for (i = 0; i < mp->num_arcs; i++) {
406 struct mdesc_node *t = mp->arcs[i].arc;
407
408 if (strcmp(mp->arcs[i].name, "fwd"))
409 continue;
410
411 if (!strcmp(t->name, "cache"))
412 fill_in_one_cache(c, t);
413 }
414 }
415}
416
417static void __init mark_core_ids(struct mdesc_node *mp, int core_id)
418{
419 unsigned int i;
420
421 for (i = 0; i < mp->num_arcs; i++) {
422 struct mdesc_node *t = mp->arcs[i].arc;
423 const u64 *id;
424
425 if (strcmp(mp->arcs[i].name, "back"))
426 continue;
427
428 if (!strcmp(t->name, "cpu")) {
429 id = md_get_property(t, "id", NULL);
430 if (*id < NR_CPUS)
431 cpu_data(*id).core_id = core_id;
432 } else {
433 unsigned int j;
434
435 for (j = 0; j < t->num_arcs; j++) {
436 struct mdesc_node *n = t->arcs[j].arc;
437
438 if (strcmp(t->arcs[j].name, "back"))
439 continue;
440
441 if (strcmp(n->name, "cpu"))
442 continue;
443
444 id = md_get_property(n, "id", NULL);
445 if (*id < NR_CPUS)
446 cpu_data(*id).core_id = core_id;
447 }
448 }
449 }
450}
451
452static void __init set_core_ids(void)
453{
454 struct mdesc_node *mp;
455 int idx;
456
457 idx = 1;
458 md_for_each_node_by_name(mp, "cache") {
459 const u64 *level = md_get_property(mp, "level", NULL);
460 const char *type;
461 int len;
462
463 if (*level != 1)
464 continue;
465
466 type = md_get_property(mp, "type", &len);
467 if (!find_in_proplist(type, "instn", len))
468 continue;
469
470 mark_core_ids(mp, idx);
471
472 idx++;
473 }
474}
475
476static void __init get_one_mondo_bits(const u64 *p, unsigned int *mask, unsigned char def)
477{
478 u64 val;
479
480 if (!p)
481 goto use_default;
482 val = *p;
483
484 if (!val || val >= 64)
485 goto use_default;
486
487 *mask = ((1U << val) * 64U) - 1U;
488 return;
489
490use_default:
491 *mask = ((1U << def) * 64U) - 1U;
492}
493
494static void __init get_mondo_data(struct mdesc_node *mp, struct trap_per_cpu *tb)
495{
496 const u64 *val;
497
498 val = md_get_property(mp, "q-cpu-mondo-#bits", NULL);
499 get_one_mondo_bits(val, &tb->cpu_mondo_qmask, 7);
500
501 val = md_get_property(mp, "q-dev-mondo-#bits", NULL);
502 get_one_mondo_bits(val, &tb->dev_mondo_qmask, 7);
503
504 val = md_get_property(mp, "q-resumable-#bits", NULL);
505 get_one_mondo_bits(val, &tb->resum_qmask, 6);
506
507 val = md_get_property(mp, "q-nonresumable-#bits", NULL);
508 get_one_mondo_bits(val, &tb->nonresum_qmask, 2);
509}
510
511static void __init mdesc_fill_in_cpu_data(void)
512{
513 struct mdesc_node *mp;
514
515 ncpus_probed = 0;
516 md_for_each_node_by_name(mp, "cpu") {
517 const u64 *id = md_get_property(mp, "id", NULL);
518 const u64 *cfreq = md_get_property(mp, "clock-frequency", NULL);
519 struct trap_per_cpu *tb;
520 cpuinfo_sparc *c;
521 unsigned int i;
522 int cpuid;
523
524 ncpus_probed++;
525
526 cpuid = *id;
527
528#ifdef CONFIG_SMP
529 if (cpuid >= NR_CPUS)
530 continue;
531#else
532 /* On uniprocessor we only want the values for the
533 * real physical cpu the kernel booted onto, however
534 * cpu_data() only has one entry at index 0.
535 */
536 if (cpuid != real_hard_smp_processor_id())
537 continue;
538 cpuid = 0;
539#endif
540
541 c = &cpu_data(cpuid);
542 c->clock_tick = *cfreq;
543
544 tb = &trap_block[cpuid];
545 get_mondo_data(mp, tb);
546
547 for (i = 0; i < mp->num_arcs; i++) {
548 struct mdesc_node *t = mp->arcs[i].arc;
549 unsigned int j;
550
551 if (strcmp(mp->arcs[i].name, "fwd"))
552 continue;
553
554 if (!strcmp(t->name, "cache")) {
555 fill_in_one_cache(c, t);
556 continue;
557 }
558
559 for (j = 0; j < t->num_arcs; j++) {
560 struct mdesc_node *n;
561
562 n = t->arcs[j].arc;
563 if (strcmp(t->arcs[j].name, "fwd"))
564 continue;
565
566 if (!strcmp(n->name, "cache"))
567 fill_in_one_cache(c, n);
568 }
569 }
570
571#ifdef CONFIG_SMP
572 cpu_set(cpuid, cpu_present_map);
573 cpu_set(cpuid, phys_cpu_present_map);
574#endif
575
576 c->core_id = 0;
577 }
578
579 set_core_ids();
580
581 smp_fill_in_sib_core_maps();
582}
583
584void __init sun4v_mdesc_init(void)
585{
586 unsigned long len, real_len, status;
587
588 (void) sun4v_mach_desc(0UL, 0UL, &len);
589
590 printk("MDESC: Size is %lu bytes.\n", len);
591
592 main_mdesc = mdesc_early_alloc(len);
593
594 status = sun4v_mach_desc(__pa(main_mdesc), len, &real_len);
595 if (status != HV_EOK || real_len > len) {
596 prom_printf("sun4v_mach_desc fails, err(%lu), "
597 "len(%lu), real_len(%lu)\n",
598 status, len, real_len);
599 prom_halt();
600 }
601
602 len = count_nodes(main_mdesc);
603 printk("MDESC: %lu nodes.\n", len);
604
605 len = roundup_pow_of_two(len);
606
607 mdesc_hash = mdesc_early_alloc(len * sizeof(struct mdesc_node *));
608 mdesc_hash_size = len;
609
610 printk("MDESC: Hash size %lu entries.\n", len);
611
612 build_all_nodes(main_mdesc);
613
614 printk("MDESC: Built graph with %u bytes of memory.\n",
615 mdesc_early_allocated);
616
617 report_platform_properties();
618 mdesc_fill_in_cpu_data();
619}
diff --git a/arch/sparc64/kernel/pci.c b/arch/sparc64/kernel/pci.c
index d4c077dc5e85..38a32bc95d22 100644
--- a/arch/sparc64/kernel/pci.c
+++ b/arch/sparc64/kernel/pci.c
@@ -306,6 +306,20 @@ static void __init pci_controller_probe(void)
306 pci_controller_scan(pci_controller_init); 306 pci_controller_scan(pci_controller_init);
307} 307}
308 308
309static int ofpci_verbose;
310
311static int __init ofpci_debug(char *str)
312{
313 int val = 0;
314
315 get_option(&str, &val);
316 if (val)
317 ofpci_verbose = 1;
318 return 1;
319}
320
321__setup("ofpci_debug=", ofpci_debug);
322
309static unsigned long pci_parse_of_flags(u32 addr0) 323static unsigned long pci_parse_of_flags(u32 addr0)
310{ 324{
311 unsigned long flags = 0; 325 unsigned long flags = 0;
@@ -337,7 +351,9 @@ static void pci_parse_of_addrs(struct of_device *op,
337 addrs = of_get_property(node, "assigned-addresses", &proplen); 351 addrs = of_get_property(node, "assigned-addresses", &proplen);
338 if (!addrs) 352 if (!addrs)
339 return; 353 return;
340 printk(" parse addresses (%d bytes) @ %p\n", proplen, addrs); 354 if (ofpci_verbose)
355 printk(" parse addresses (%d bytes) @ %p\n",
356 proplen, addrs);
341 op_res = &op->resource[0]; 357 op_res = &op->resource[0];
342 for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) { 358 for (; proplen >= 20; proplen -= 20, addrs += 5, op_res++) {
343 struct resource *res; 359 struct resource *res;
@@ -348,8 +364,9 @@ static void pci_parse_of_addrs(struct of_device *op,
348 if (!flags) 364 if (!flags)
349 continue; 365 continue;
350 i = addrs[0] & 0xff; 366 i = addrs[0] & 0xff;
351 printk(" start: %lx, end: %lx, i: %x\n", 367 if (ofpci_verbose)
352 op_res->start, op_res->end, i); 368 printk(" start: %lx, end: %lx, i: %x\n",
369 op_res->start, op_res->end, i);
353 370
354 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) { 371 if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {
355 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2]; 372 res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];
@@ -393,8 +410,9 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
393 if (type == NULL) 410 if (type == NULL)
394 type = ""; 411 type = "";
395 412
396 printk(" create device, devfn: %x, type: %s hostcontroller(%d)\n", 413 if (ofpci_verbose)
397 devfn, type, host_controller); 414 printk(" create device, devfn: %x, type: %s\n",
415 devfn, type);
398 416
399 dev->bus = bus; 417 dev->bus = bus;
400 dev->sysdata = node; 418 dev->sysdata = node;
@@ -434,8 +452,9 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
434 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus), 452 sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),
435 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); 453 dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));
436 } 454 }
437 printk(" class: 0x%x device name: %s\n", 455 if (ofpci_verbose)
438 dev->class, pci_name(dev)); 456 printk(" class: 0x%x device name: %s\n",
457 dev->class, pci_name(dev));
439 458
440 /* I have seen IDE devices which will not respond to 459 /* I have seen IDE devices which will not respond to
441 * the bmdma simplex check reads if bus mastering is 460 * the bmdma simplex check reads if bus mastering is
@@ -469,7 +488,8 @@ struct pci_dev *of_create_pci_dev(struct pci_pbm_info *pbm,
469 } 488 }
470 pci_parse_of_addrs(sd->op, node, dev); 489 pci_parse_of_addrs(sd->op, node, dev);
471 490
472 printk(" adding to system ...\n"); 491 if (ofpci_verbose)
492 printk(" adding to system ...\n");
473 493
474 pci_device_add(dev, bus); 494 pci_device_add(dev, bus);
475 495
@@ -547,7 +567,8 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
547 unsigned int flags; 567 unsigned int flags;
548 u64 size; 568 u64 size;
549 569
550 printk("of_scan_pci_bridge(%s)\n", node->full_name); 570 if (ofpci_verbose)
571 printk("of_scan_pci_bridge(%s)\n", node->full_name);
551 572
552 /* parse bus-range property */ 573 /* parse bus-range property */
553 busrange = of_get_property(node, "bus-range", &len); 574 busrange = of_get_property(node, "bus-range", &len);
@@ -632,7 +653,8 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
632simba_cont: 653simba_cont:
633 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 654 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
634 bus->number); 655 bus->number);
635 printk(" bus name: %s\n", bus->name); 656 if (ofpci_verbose)
657 printk(" bus name: %s\n", bus->name);
636 658
637 pci_of_scan_bus(pbm, node, bus); 659 pci_of_scan_bus(pbm, node, bus);
638} 660}
@@ -646,12 +668,14 @@ static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm,
646 int reglen, devfn; 668 int reglen, devfn;
647 struct pci_dev *dev; 669 struct pci_dev *dev;
648 670
649 printk("PCI: scan_bus[%s] bus no %d\n", 671 if (ofpci_verbose)
650 node->full_name, bus->number); 672 printk("PCI: scan_bus[%s] bus no %d\n",
673 node->full_name, bus->number);
651 674
652 child = NULL; 675 child = NULL;
653 while ((child = of_get_next_child(node, child)) != NULL) { 676 while ((child = of_get_next_child(node, child)) != NULL) {
654 printk(" * %s\n", child->full_name); 677 if (ofpci_verbose)
678 printk(" * %s\n", child->full_name);
655 reg = of_get_property(child, "reg", &reglen); 679 reg = of_get_property(child, "reg", &reglen);
656 if (reg == NULL || reglen < 20) 680 if (reg == NULL || reglen < 20)
657 continue; 681 continue;
@@ -661,7 +685,9 @@ static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm,
661 dev = of_create_pci_dev(pbm, child, bus, devfn, 0); 685 dev = of_create_pci_dev(pbm, child, bus, devfn, 0);
662 if (!dev) 686 if (!dev)
663 continue; 687 continue;
664 printk("PCI: dev header type: %x\n", dev->hdr_type); 688 if (ofpci_verbose)
689 printk("PCI: dev header type: %x\n",
690 dev->hdr_type);
665 691
666 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE || 692 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
667 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 693 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
diff --git a/arch/sparc64/kernel/pci_sabre.c b/arch/sparc64/kernel/pci_sabre.c
index e2377796de89..323d6c278518 100644
--- a/arch/sparc64/kernel/pci_sabre.c
+++ b/arch/sparc64/kernel/pci_sabre.c
@@ -762,9 +762,10 @@ void sabre_init(struct device_node *dp, char *model_name)
762 /* Of course, Sun has to encode things a thousand 762 /* Of course, Sun has to encode things a thousand
763 * different ways, inconsistently. 763 * different ways, inconsistently.
764 */ 764 */
765 cpu_find_by_instance(0, &dp, NULL); 765 for_each_node_by_type(dp, "cpu") {
766 if (!strcmp(dp->name, "SUNW,UltraSPARC-IIe")) 766 if (!strcmp(dp->name, "SUNW,UltraSPARC-IIe"))
767 hummingbird_p = 1; 767 hummingbird_p = 1;
768 }
768 } 769 }
769 } 770 }
770 771
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index 044e8ec4c0f5..6b3fe2c1d65e 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -12,6 +12,7 @@
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <linux/msi.h> 14#include <linux/msi.h>
15#include <linux/log2.h>
15 16
16#include <asm/iommu.h> 17#include <asm/iommu.h>
17#include <asm/irq.h> 18#include <asm/irq.h>
@@ -26,6 +27,9 @@
26 27
27#include "pci_sun4v.h" 28#include "pci_sun4v.h"
28 29
30static unsigned long vpci_major = 1;
31static unsigned long vpci_minor = 1;
32
29#define PGLIST_NENTS (PAGE_SIZE / sizeof(u64)) 33#define PGLIST_NENTS (PAGE_SIZE / sizeof(u64))
30 34
31struct iommu_batch { 35struct iommu_batch {
@@ -638,9 +642,8 @@ static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
638{ 642{
639 struct iommu *iommu = pbm->iommu; 643 struct iommu *iommu = pbm->iommu;
640 struct property *prop; 644 struct property *prop;
641 unsigned long num_tsb_entries, sz; 645 unsigned long num_tsb_entries, sz, tsbsize;
642 u32 vdma[2], dma_mask, dma_offset; 646 u32 vdma[2], dma_mask, dma_offset;
643 int tsbsize;
644 647
645 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL); 648 prop = of_find_property(pbm->prom_node, "virtual-dma", NULL);
646 if (prop) { 649 if (prop) {
@@ -654,31 +657,15 @@ static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
654 vdma[1] = 0x80000000; 657 vdma[1] = 0x80000000;
655 } 658 }
656 659
657 dma_mask = vdma[0]; 660 if ((vdma[0] | vdma[1]) & ~IO_PAGE_MASK) {
658 switch (vdma[1]) { 661 prom_printf("PCI-SUN4V: strange virtual-dma[%08x:%08x].\n",
659 case 0x20000000: 662 vdma[0], vdma[1]);
660 dma_mask |= 0x1fffffff; 663 prom_halt();
661 tsbsize = 64;
662 break;
663
664 case 0x40000000:
665 dma_mask |= 0x3fffffff;
666 tsbsize = 128;
667 break;
668
669 case 0x80000000:
670 dma_mask |= 0x7fffffff;
671 tsbsize = 256;
672 break;
673
674 default:
675 prom_printf("PCI-SUN4V: strange virtual-dma size.\n");
676 prom_halt();
677 }; 664 };
678 665
679 tsbsize *= (8 * 1024); 666 dma_mask = (roundup_pow_of_two(vdma[1]) - 1UL);
680 667 num_tsb_entries = vdma[1] / IO_PAGE_SIZE;
681 num_tsb_entries = tsbsize / sizeof(iopte_t); 668 tsbsize = num_tsb_entries * sizeof(iopte_t);
682 669
683 dma_offset = vdma[0]; 670 dma_offset = vdma[0];
684 671
@@ -689,7 +676,7 @@ static void pci_sun4v_iommu_init(struct pci_pbm_info *pbm)
689 iommu->dma_addr_mask = dma_mask; 676 iommu->dma_addr_mask = dma_mask;
690 677
691 /* Allocate and initialize the free area map. */ 678 /* Allocate and initialize the free area map. */
692 sz = num_tsb_entries / 8; 679 sz = (num_tsb_entries + 7) / 8;
693 sz = (sz + 7UL) & ~7UL; 680 sz = (sz + 7UL) & ~7UL;
694 iommu->arena.map = kzalloc(sz, GFP_KERNEL); 681 iommu->arena.map = kzalloc(sz, GFP_KERNEL);
695 if (!iommu->arena.map) { 682 if (!iommu->arena.map) {
@@ -1178,6 +1165,7 @@ static void pci_sun4v_pbm_init(struct pci_controller_info *p, struct device_node
1178 1165
1179void sun4v_pci_init(struct device_node *dp, char *model_name) 1166void sun4v_pci_init(struct device_node *dp, char *model_name)
1180{ 1167{
1168 static int hvapi_negotiated = 0;
1181 struct pci_controller_info *p; 1169 struct pci_controller_info *p;
1182 struct pci_pbm_info *pbm; 1170 struct pci_pbm_info *pbm;
1183 struct iommu *iommu; 1171 struct iommu *iommu;
@@ -1186,6 +1174,20 @@ void sun4v_pci_init(struct device_node *dp, char *model_name)
1186 u32 devhandle; 1174 u32 devhandle;
1187 int i; 1175 int i;
1188 1176
1177 if (!hvapi_negotiated++) {
1178 int err = sun4v_hvapi_register(HV_GRP_PCI,
1179 vpci_major,
1180 &vpci_minor);
1181
1182 if (err) {
1183 prom_printf("SUN4V_PCI: Could not register hvapi, "
1184 "err=%d\n", err);
1185 prom_halt();
1186 }
1187 printk("SUN4V_PCI: Registered hvapi major[%lu] minor[%lu]\n",
1188 vpci_major, vpci_minor);
1189 }
1190
1189 prop = of_find_property(dp, "reg", NULL); 1191 prop = of_find_property(dp, "reg", NULL);
1190 regs = prop->value; 1192 regs = prop->value;
1191 1193
diff --git a/arch/sparc64/kernel/power.c b/arch/sparc64/kernel/power.c
index 699b24b890df..5d6adea3967f 100644
--- a/arch/sparc64/kernel/power.c
+++ b/arch/sparc64/kernel/power.c
@@ -19,6 +19,7 @@
19#include <asm/prom.h> 19#include <asm/prom.h>
20#include <asm/of_device.h> 20#include <asm/of_device.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/sstate.h>
22 23
23#include <linux/unistd.h> 24#include <linux/unistd.h>
24 25
@@ -53,6 +54,7 @@ static void (*poweroff_method)(void) = machine_alt_power_off;
53 54
54void machine_power_off(void) 55void machine_power_off(void)
55{ 56{
57 sstate_poweroff();
56 if (!serial_console || scons_pwroff) { 58 if (!serial_console || scons_pwroff) {
57#ifdef CONFIG_PCI 59#ifdef CONFIG_PCI
58 if (power_reg) { 60 if (power_reg) {
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 952762bfb4c0..f5f97e2c669c 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -45,6 +45,7 @@
45#include <asm/mmu_context.h> 45#include <asm/mmu_context.h>
46#include <asm/unistd.h> 46#include <asm/unistd.h>
47#include <asm/hypervisor.h> 47#include <asm/hypervisor.h>
48#include <asm/sstate.h>
48 49
49/* #define VERBOSE_SHOWREGS */ 50/* #define VERBOSE_SHOWREGS */
50 51
@@ -106,6 +107,7 @@ extern void (*prom_keyboard)(void);
106 107
107void machine_halt(void) 108void machine_halt(void)
108{ 109{
110 sstate_halt();
109 if (!serial_console && prom_palette) 111 if (!serial_console && prom_palette)
110 prom_palette (1); 112 prom_palette (1);
111 if (prom_keyboard) 113 if (prom_keyboard)
@@ -116,6 +118,7 @@ void machine_halt(void)
116 118
117void machine_alt_power_off(void) 119void machine_alt_power_off(void)
118{ 120{
121 sstate_poweroff();
119 if (!serial_console && prom_palette) 122 if (!serial_console && prom_palette)
120 prom_palette(1); 123 prom_palette(1);
121 if (prom_keyboard) 124 if (prom_keyboard)
@@ -128,6 +131,7 @@ void machine_restart(char * cmd)
128{ 131{
129 char *p; 132 char *p;
130 133
134 sstate_reboot();
131 p = strchr (reboot_command, '\n'); 135 p = strchr (reboot_command, '\n');
132 if (p) *p = 0; 136 if (p) *p = 0;
133 if (!serial_console && prom_palette) 137 if (!serial_console && prom_palette)
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 02830e4671f5..dad4b3ba705f 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -28,6 +28,7 @@
28#include <asm/irq.h> 28#include <asm/irq.h>
29#include <asm/asi.h> 29#include <asm/asi.h>
30#include <asm/upa.h> 30#include <asm/upa.h>
31#include <asm/smp.h>
31 32
32static struct device_node *allnodes; 33static struct device_node *allnodes;
33 34
@@ -1665,6 +1666,150 @@ static struct device_node * __init build_tree(struct device_node *parent, phandl
1665 return ret; 1666 return ret;
1666} 1667}
1667 1668
1669static const char *get_mid_prop(void)
1670{
1671 return (tlb_type == spitfire ? "upa-portid" : "portid");
1672}
1673
1674struct device_node *of_find_node_by_cpuid(int cpuid)
1675{
1676 struct device_node *dp;
1677 const char *mid_prop = get_mid_prop();
1678
1679 for_each_node_by_type(dp, "cpu") {
1680 int id = of_getintprop_default(dp, mid_prop, -1);
1681 const char *this_mid_prop = mid_prop;
1682
1683 if (id < 0) {
1684 this_mid_prop = "cpuid";
1685 id = of_getintprop_default(dp, this_mid_prop, -1);
1686 }
1687
1688 if (id < 0) {
1689 prom_printf("OF: Serious problem, cpu lacks "
1690 "%s property", this_mid_prop);
1691 prom_halt();
1692 }
1693 if (cpuid == id)
1694 return dp;
1695 }
1696 return NULL;
1697}
1698
1699static void __init of_fill_in_cpu_data(void)
1700{
1701 struct device_node *dp;
1702 const char *mid_prop = get_mid_prop();
1703
1704 ncpus_probed = 0;
1705 for_each_node_by_type(dp, "cpu") {
1706 int cpuid = of_getintprop_default(dp, mid_prop, -1);
1707 const char *this_mid_prop = mid_prop;
1708 struct device_node *portid_parent;
1709 int portid = -1;
1710
1711 portid_parent = NULL;
1712 if (cpuid < 0) {
1713 this_mid_prop = "cpuid";
1714 cpuid = of_getintprop_default(dp, this_mid_prop, -1);
1715 if (cpuid >= 0) {
1716 int limit = 2;
1717
1718 portid_parent = dp;
1719 while (limit--) {
1720 portid_parent = portid_parent->parent;
1721 if (!portid_parent)
1722 break;
1723 portid = of_getintprop_default(portid_parent,
1724 "portid", -1);
1725 if (portid >= 0)
1726 break;
1727 }
1728 }
1729 }
1730
1731 if (cpuid < 0) {
1732 prom_printf("OF: Serious problem, cpu lacks "
1733 "%s property", this_mid_prop);
1734 prom_halt();
1735 }
1736
1737 ncpus_probed++;
1738
1739#ifdef CONFIG_SMP
1740 if (cpuid >= NR_CPUS)
1741 continue;
1742#else
1743 /* On uniprocessor we only want the values for the
1744 * real physical cpu the kernel booted onto, however
1745 * cpu_data() only has one entry at index 0.
1746 */
1747 if (cpuid != real_hard_smp_processor_id())
1748 continue;
1749 cpuid = 0;
1750#endif
1751
1752 cpu_data(cpuid).clock_tick =
1753 of_getintprop_default(dp, "clock-frequency", 0);
1754
1755 if (portid_parent) {
1756 cpu_data(cpuid).dcache_size =
1757 of_getintprop_default(dp, "l1-dcache-size",
1758 16 * 1024);
1759 cpu_data(cpuid).dcache_line_size =
1760 of_getintprop_default(dp, "l1-dcache-line-size",
1761 32);
1762 cpu_data(cpuid).icache_size =
1763 of_getintprop_default(dp, "l1-icache-size",
1764 8 * 1024);
1765 cpu_data(cpuid).icache_line_size =
1766 of_getintprop_default(dp, "l1-icache-line-size",
1767 32);
1768 cpu_data(cpuid).ecache_size =
1769 of_getintprop_default(dp, "l2-cache-size", 0);
1770 cpu_data(cpuid).ecache_line_size =
1771 of_getintprop_default(dp, "l2-cache-line-size", 0);
1772 if (!cpu_data(cpuid).ecache_size ||
1773 !cpu_data(cpuid).ecache_line_size) {
1774 cpu_data(cpuid).ecache_size =
1775 of_getintprop_default(portid_parent,
1776 "l2-cache-size",
1777 (4 * 1024 * 1024));
1778 cpu_data(cpuid).ecache_line_size =
1779 of_getintprop_default(portid_parent,
1780 "l2-cache-line-size", 64);
1781 }
1782
1783 cpu_data(cpuid).core_id = portid + 1;
1784 } else {
1785 cpu_data(cpuid).dcache_size =
1786 of_getintprop_default(dp, "dcache-size", 16 * 1024);
1787 cpu_data(cpuid).dcache_line_size =
1788 of_getintprop_default(dp, "dcache-line-size", 32);
1789
1790 cpu_data(cpuid).icache_size =
1791 of_getintprop_default(dp, "icache-size", 16 * 1024);
1792 cpu_data(cpuid).icache_line_size =
1793 of_getintprop_default(dp, "icache-line-size", 32);
1794
1795 cpu_data(cpuid).ecache_size =
1796 of_getintprop_default(dp, "ecache-size",
1797 (4 * 1024 * 1024));
1798 cpu_data(cpuid).ecache_line_size =
1799 of_getintprop_default(dp, "ecache-line-size", 64);
1800
1801 cpu_data(cpuid).core_id = 0;
1802 }
1803
1804#ifdef CONFIG_SMP
1805 cpu_set(cpuid, cpu_present_map);
1806 cpu_set(cpuid, phys_cpu_present_map);
1807#endif
1808 }
1809
1810 smp_fill_in_sib_core_maps();
1811}
1812
1668void __init prom_build_devicetree(void) 1813void __init prom_build_devicetree(void)
1669{ 1814{
1670 struct device_node **nextp; 1815 struct device_node **nextp;
@@ -1679,4 +1824,7 @@ void __init prom_build_devicetree(void)
1679 &nextp); 1824 &nextp);
1680 printk("PROM: Built device tree with %u bytes of memory.\n", 1825 printk("PROM: Built device tree with %u bytes of memory.\n",
1681 prom_early_allocated); 1826 prom_early_allocated);
1827
1828 if (tlb_type != hypervisor)
1829 of_fill_in_cpu_data();
1682} 1830}
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index dea9c3c9ec5f..de9b4c13f1c7 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -46,11 +46,17 @@
46#include <asm/sections.h> 46#include <asm/sections.h>
47#include <asm/setup.h> 47#include <asm/setup.h>
48#include <asm/mmu.h> 48#include <asm/mmu.h>
49#include <asm/ns87303.h>
49 50
50#ifdef CONFIG_IP_PNP 51#ifdef CONFIG_IP_PNP
51#include <net/ipconfig.h> 52#include <net/ipconfig.h>
52#endif 53#endif
53 54
55/* Used to synchronize accesses to NatSemi SUPER I/O chip configure
56 * operations in asm/ns87303.h
57 */
58DEFINE_SPINLOCK(ns87303_lock);
59
54struct screen_info screen_info = { 60struct screen_info screen_info = {
55 0, 0, /* orig-x, orig-y */ 61 0, 0, /* orig-x, orig-y */
56 0, /* unused */ 62 0, /* unused */
@@ -370,8 +376,6 @@ void __init setup_arch(char **cmdline_p)
370 init_cur_cpu_trap(current_thread_info()); 376 init_cur_cpu_trap(current_thread_info());
371 377
372 paging_init(); 378 paging_init();
373
374 smp_setup_cpu_possible_map();
375} 379}
376 380
377static int __init set_preferred_console(void) 381static int __init set_preferred_console(void)
@@ -424,7 +428,7 @@ extern void mmu_info(struct seq_file *);
424unsigned int dcache_parity_tl1_occurred; 428unsigned int dcache_parity_tl1_occurred;
425unsigned int icache_parity_tl1_occurred; 429unsigned int icache_parity_tl1_occurred;
426 430
427static int ncpus_probed; 431int ncpus_probed;
428 432
429static int show_cpuinfo(struct seq_file *m, void *__unused) 433static int show_cpuinfo(struct seq_file *m, void *__unused)
430{ 434{
@@ -516,14 +520,6 @@ static int __init topology_init(void)
516 520
517 err = -ENOMEM; 521 err = -ENOMEM;
518 522
519 /* Count the number of physically present processors in
520 * the machine, even on uniprocessor, so that /proc/cpuinfo
521 * output is consistent with 2.4.x
522 */
523 ncpus_probed = 0;
524 while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
525 ncpus_probed++;
526
527 for_each_possible_cpu(i) { 523 for_each_possible_cpu(i) {
528 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); 524 struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
529 if (p) { 525 if (p) {
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 24fdf1d0adc5..c550bba3490a 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -40,6 +40,7 @@
40#include <asm/tlb.h> 40#include <asm/tlb.h>
41#include <asm/sections.h> 41#include <asm/sections.h>
42#include <asm/prom.h> 42#include <asm/prom.h>
43#include <asm/mdesc.h>
43 44
44extern void calibrate_delay(void); 45extern void calibrate_delay(void);
45 46
@@ -75,53 +76,6 @@ void smp_bogo(struct seq_file *m)
75 i, cpu_data(i).clock_tick); 76 i, cpu_data(i).clock_tick);
76} 77}
77 78
78void __init smp_store_cpu_info(int id)
79{
80 struct device_node *dp;
81 int def;
82
83 cpu_data(id).udelay_val = loops_per_jiffy;
84
85 cpu_find_by_mid(id, &dp);
86 cpu_data(id).clock_tick =
87 of_getintprop_default(dp, "clock-frequency", 0);
88
89 def = ((tlb_type == hypervisor) ? (8 * 1024) : (16 * 1024));
90 cpu_data(id).dcache_size =
91 of_getintprop_default(dp, "dcache-size", def);
92
93 def = 32;
94 cpu_data(id).dcache_line_size =
95 of_getintprop_default(dp, "dcache-line-size", def);
96
97 def = 16 * 1024;
98 cpu_data(id).icache_size =
99 of_getintprop_default(dp, "icache-size", def);
100
101 def = 32;
102 cpu_data(id).icache_line_size =
103 of_getintprop_default(dp, "icache-line-size", def);
104
105 def = ((tlb_type == hypervisor) ?
106 (3 * 1024 * 1024) :
107 (4 * 1024 * 1024));
108 cpu_data(id).ecache_size =
109 of_getintprop_default(dp, "ecache-size", def);
110
111 def = 64;
112 cpu_data(id).ecache_line_size =
113 of_getintprop_default(dp, "ecache-line-size", def);
114
115 printk("CPU[%d]: Caches "
116 "D[sz(%d):line_sz(%d)] "
117 "I[sz(%d):line_sz(%d)] "
118 "E[sz(%d):line_sz(%d)]\n",
119 id,
120 cpu_data(id).dcache_size, cpu_data(id).dcache_line_size,
121 cpu_data(id).icache_size, cpu_data(id).icache_line_size,
122 cpu_data(id).ecache_size, cpu_data(id).ecache_line_size);
123}
124
125extern void setup_sparc64_timer(void); 79extern void setup_sparc64_timer(void);
126 80
127static volatile unsigned long callin_flag = 0; 81static volatile unsigned long callin_flag = 0;
@@ -145,7 +99,7 @@ void __init smp_callin(void)
145 local_irq_enable(); 99 local_irq_enable();
146 100
147 calibrate_delay(); 101 calibrate_delay();
148 smp_store_cpu_info(cpuid); 102 cpu_data(cpuid).udelay_val = loops_per_jiffy;
149 callin_flag = 1; 103 callin_flag = 1;
150 __asm__ __volatile__("membar #Sync\n\t" 104 __asm__ __volatile__("membar #Sync\n\t"
151 "flush %%g6" : : : "memory"); 105 "flush %%g6" : : : "memory");
@@ -340,9 +294,8 @@ static int __devinit smp_boot_one_cpu(unsigned int cpu)
340 294
341 prom_startcpu_cpuid(cpu, entry, cookie); 295 prom_startcpu_cpuid(cpu, entry, cookie);
342 } else { 296 } else {
343 struct device_node *dp; 297 struct device_node *dp = of_find_node_by_cpuid(cpu);
344 298
345 cpu_find_by_mid(cpu, &dp);
346 prom_startcpu(dp->node, entry, cookie); 299 prom_startcpu(dp->node, entry, cookie);
347 } 300 }
348 301
@@ -447,7 +400,7 @@ static __inline__ void spitfire_xcall_deliver(u64 data0, u64 data1, u64 data2, c
447static void cheetah_xcall_deliver(u64 data0, u64 data1, u64 data2, cpumask_t mask) 400static void cheetah_xcall_deliver(u64 data0, u64 data1, u64 data2, cpumask_t mask)
448{ 401{
449 u64 pstate, ver; 402 u64 pstate, ver;
450 int nack_busy_id, is_jbus; 403 int nack_busy_id, is_jbus, need_more;
451 404
452 if (cpus_empty(mask)) 405 if (cpus_empty(mask))
453 return; 406 return;
@@ -463,6 +416,7 @@ static void cheetah_xcall_deliver(u64 data0, u64 data1, u64 data2, cpumask_t mas
463 __asm__ __volatile__("rdpr %%pstate, %0" : "=r" (pstate)); 416 __asm__ __volatile__("rdpr %%pstate, %0" : "=r" (pstate));
464 417
465retry: 418retry:
419 need_more = 0;
466 __asm__ __volatile__("wrpr %0, %1, %%pstate\n\t" 420 __asm__ __volatile__("wrpr %0, %1, %%pstate\n\t"
467 : : "r" (pstate), "i" (PSTATE_IE)); 421 : : "r" (pstate), "i" (PSTATE_IE));
468 422
@@ -491,6 +445,10 @@ retry:
491 : /* no outputs */ 445 : /* no outputs */
492 : "r" (target), "i" (ASI_INTR_W)); 446 : "r" (target), "i" (ASI_INTR_W));
493 nack_busy_id++; 447 nack_busy_id++;
448 if (nack_busy_id == 32) {
449 need_more = 1;
450 break;
451 }
494 } 452 }
495 } 453 }
496 454
@@ -507,6 +465,16 @@ retry:
507 if (dispatch_stat == 0UL) { 465 if (dispatch_stat == 0UL) {
508 __asm__ __volatile__("wrpr %0, 0x0, %%pstate" 466 __asm__ __volatile__("wrpr %0, 0x0, %%pstate"
509 : : "r" (pstate)); 467 : : "r" (pstate));
468 if (unlikely(need_more)) {
469 int i, cnt = 0;
470 for_each_cpu_mask(i, mask) {
471 cpu_clear(i, mask);
472 cnt++;
473 if (cnt == 32)
474 break;
475 }
476 goto retry;
477 }
510 return; 478 return;
511 } 479 }
512 if (!--stuck) 480 if (!--stuck)
@@ -544,6 +512,8 @@ retry:
544 if ((dispatch_stat & check_mask) == 0) 512 if ((dispatch_stat & check_mask) == 0)
545 cpu_clear(i, mask); 513 cpu_clear(i, mask);
546 this_busy_nack += 2; 514 this_busy_nack += 2;
515 if (this_busy_nack == 64)
516 break;
547 } 517 }
548 518
549 goto retry; 519 goto retry;
@@ -1191,23 +1161,14 @@ int setup_profiling_timer(unsigned int multiplier)
1191 1161
1192static void __init smp_tune_scheduling(void) 1162static void __init smp_tune_scheduling(void)
1193{ 1163{
1194 struct device_node *dp; 1164 unsigned int smallest = ~0U;
1195 int instance; 1165 int i;
1196 unsigned int def, smallest = ~0U;
1197
1198 def = ((tlb_type == hypervisor) ?
1199 (3 * 1024 * 1024) :
1200 (4 * 1024 * 1024));
1201 1166
1202 instance = 0; 1167 for (i = 0; i < NR_CPUS; i++) {
1203 while (!cpu_find_by_instance(instance, &dp, NULL)) { 1168 unsigned int val = cpu_data(i).ecache_size;
1204 unsigned int val;
1205 1169
1206 val = of_getintprop_default(dp, "ecache-size", def); 1170 if (val && val < smallest)
1207 if (val < smallest)
1208 smallest = val; 1171 smallest = val;
1209
1210 instance++;
1211 } 1172 }
1212 1173
1213 /* Any value less than 256K is nonsense. */ 1174 /* Any value less than 256K is nonsense. */
@@ -1230,58 +1191,42 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
1230 int i; 1191 int i;
1231 1192
1232 if (num_possible_cpus() > max_cpus) { 1193 if (num_possible_cpus() > max_cpus) {
1233 int instance, mid; 1194 for_each_possible_cpu(i) {
1234 1195 if (i != boot_cpu_id) {
1235 instance = 0; 1196 cpu_clear(i, phys_cpu_present_map);
1236 while (!cpu_find_by_instance(instance, NULL, &mid)) { 1197 cpu_clear(i, cpu_present_map);
1237 if (mid != boot_cpu_id) {
1238 cpu_clear(mid, phys_cpu_present_map);
1239 cpu_clear(mid, cpu_present_map);
1240 if (num_possible_cpus() <= max_cpus) 1198 if (num_possible_cpus() <= max_cpus)
1241 break; 1199 break;
1242 } 1200 }
1243 instance++;
1244 } 1201 }
1245 } 1202 }
1246 1203
1247 for_each_possible_cpu(i) { 1204 cpu_data(boot_cpu_id).udelay_val = loops_per_jiffy;
1248 if (tlb_type == hypervisor) {
1249 int j;
1250
1251 /* XXX get this mapping from machine description */
1252 for_each_possible_cpu(j) {
1253 if ((j >> 2) == (i >> 2))
1254 cpu_set(j, cpu_sibling_map[i]);
1255 }
1256 } else {
1257 cpu_set(i, cpu_sibling_map[i]);
1258 }
1259 }
1260
1261 smp_store_cpu_info(boot_cpu_id);
1262 smp_tune_scheduling(); 1205 smp_tune_scheduling();
1263} 1206}
1264 1207
1265/* Set this up early so that things like the scheduler can init 1208void __devinit smp_prepare_boot_cpu(void)
1266 * properly. We use the same cpu mask for both the present and
1267 * possible cpu map.
1268 */
1269void __init smp_setup_cpu_possible_map(void)
1270{ 1209{
1271 int instance, mid;
1272
1273 instance = 0;
1274 while (!cpu_find_by_instance(instance, NULL, &mid)) {
1275 if (mid < NR_CPUS) {
1276 cpu_set(mid, phys_cpu_present_map);
1277 cpu_set(mid, cpu_present_map);
1278 }
1279 instance++;
1280 }
1281} 1210}
1282 1211
1283void __devinit smp_prepare_boot_cpu(void) 1212void __devinit smp_fill_in_sib_core_maps(void)
1284{ 1213{
1214 unsigned int i;
1215
1216 for_each_possible_cpu(i) {
1217 unsigned int j;
1218
1219 if (cpu_data(i).core_id == 0) {
1220 cpu_set(i, cpu_sibling_map[i]);
1221 continue;
1222 }
1223
1224 for_each_possible_cpu(j) {
1225 if (cpu_data(i).core_id ==
1226 cpu_data(j).core_id)
1227 cpu_set(j, cpu_sibling_map[i]);
1228 }
1229 }
1285} 1230}
1286 1231
1287int __cpuinit __cpu_up(unsigned int cpu) 1232int __cpuinit __cpu_up(unsigned int cpu)
@@ -1337,7 +1282,7 @@ unsigned long __per_cpu_shift __read_mostly;
1337EXPORT_SYMBOL(__per_cpu_base); 1282EXPORT_SYMBOL(__per_cpu_base);
1338EXPORT_SYMBOL(__per_cpu_shift); 1283EXPORT_SYMBOL(__per_cpu_shift);
1339 1284
1340void __init setup_per_cpu_areas(void) 1285void __init real_setup_per_cpu_areas(void)
1341{ 1286{
1342 unsigned long goal, size, i; 1287 unsigned long goal, size, i;
1343 char *ptr; 1288 char *ptr;
diff --git a/arch/sparc64/kernel/sstate.c b/arch/sparc64/kernel/sstate.c
new file mode 100644
index 000000000000..5b6e75b7f052
--- /dev/null
+++ b/arch/sparc64/kernel/sstate.c
@@ -0,0 +1,104 @@
1/* sstate.c: System soft state support.
2 *
3 * Copyright (C) 2007 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/kernel.h>
7#include <linux/notifier.h>
8#include <linux/init.h>
9
10#include <asm/hypervisor.h>
11#include <asm/sstate.h>
12#include <asm/oplib.h>
13#include <asm/head.h>
14#include <asm/io.h>
15
16static int hv_supports_soft_state;
17
18static unsigned long kimage_addr_to_ra(const char *p)
19{
20 unsigned long val = (unsigned long) p;
21
22 return kern_base + (val - KERNBASE);
23}
24
25static void do_set_sstate(unsigned long state, const char *msg)
26{
27 unsigned long err;
28
29 if (!hv_supports_soft_state)
30 return;
31
32 err = sun4v_mach_set_soft_state(state, kimage_addr_to_ra(msg));
33 if (err) {
34 printk(KERN_WARNING "SSTATE: Failed to set soft-state to "
35 "state[%lx] msg[%s], err=%lu\n",
36 state, msg, err);
37 }
38}
39
40static const char booting_msg[32] __attribute__((aligned(32))) =
41 "Linux booting";
42static const char running_msg[32] __attribute__((aligned(32))) =
43 "Linux running";
44static const char halting_msg[32] __attribute__((aligned(32))) =
45 "Linux halting";
46static const char poweroff_msg[32] __attribute__((aligned(32))) =
47 "Linux powering off";
48static const char rebooting_msg[32] __attribute__((aligned(32))) =
49 "Linux rebooting";
50static const char panicing_msg[32] __attribute__((aligned(32))) =
51 "Linux panicing";
52
53void sstate_booting(void)
54{
55 do_set_sstate(HV_SOFT_STATE_TRANSITION, booting_msg);
56}
57
58void sstate_running(void)
59{
60 do_set_sstate(HV_SOFT_STATE_NORMAL, running_msg);
61}
62
63void sstate_halt(void)
64{
65 do_set_sstate(HV_SOFT_STATE_TRANSITION, halting_msg);
66}
67
68void sstate_poweroff(void)
69{
70 do_set_sstate(HV_SOFT_STATE_TRANSITION, poweroff_msg);
71}
72
73void sstate_reboot(void)
74{
75 do_set_sstate(HV_SOFT_STATE_TRANSITION, rebooting_msg);
76}
77
78static int sstate_panic_event(struct notifier_block *n, unsigned long event, void *ptr)
79{
80 do_set_sstate(HV_SOFT_STATE_TRANSITION, panicing_msg);
81
82 return NOTIFY_DONE;
83}
84
85static struct notifier_block sstate_panic_block = {
86 .notifier_call = sstate_panic_event,
87 .priority = INT_MAX,
88};
89
90void __init sun4v_sstate_init(void)
91{
92 unsigned long major, minor;
93
94 major = 1;
95 minor = 0;
96 if (sun4v_hvapi_register(HV_GRP_SOFT_STATE, major, &minor))
97 return;
98
99 hv_supports_soft_state = 1;
100
101 prom_sun4v_guest_soft_state();
102 atomic_notifier_chain_register(&panic_notifier_list,
103 &sstate_panic_block);
104}
diff --git a/arch/sparc64/kernel/sun4v_ivec.S b/arch/sparc64/kernel/sun4v_ivec.S
index 405855dd886b..574bc248bca6 100644
--- a/arch/sparc64/kernel/sun4v_ivec.S
+++ b/arch/sparc64/kernel/sun4v_ivec.S
@@ -22,12 +22,12 @@ sun4v_cpu_mondo:
22 be,pn %xcc, sun4v_cpu_mondo_queue_empty 22 be,pn %xcc, sun4v_cpu_mondo_queue_empty
23 nop 23 nop
24 24
25 /* Get &trap_block[smp_processor_id()] into %g3. */ 25 /* Get &trap_block[smp_processor_id()] into %g4. */
26 ldxa [%g0] ASI_SCRATCHPAD, %g3 26 ldxa [%g0] ASI_SCRATCHPAD, %g4
27 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3 27 sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4
28 28
29 /* Get CPU mondo queue base phys address into %g7. */ 29 /* Get CPU mondo queue base phys address into %g7. */
30 ldx [%g3 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 30 ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7
31 31
32 /* Now get the cross-call arguments and handler PC, same 32 /* Now get the cross-call arguments and handler PC, same
33 * layout as sun4u: 33 * layout as sun4u:
@@ -47,8 +47,7 @@ sun4v_cpu_mondo:
47 add %g2, 0x40 - 0x8 - 0x8, %g2 47 add %g2, 0x40 - 0x8 - 0x8, %g2
48 48
49 /* Update queue head pointer. */ 49 /* Update queue head pointer. */
50 sethi %hi(8192 - 1), %g4 50 lduw [%g4 + TRAP_PER_CPU_CPU_MONDO_QMASK], %g4
51 or %g4, %lo(8192 - 1), %g4
52 and %g2, %g4, %g2 51 and %g2, %g4, %g2
53 52
54 mov INTRQ_CPU_MONDO_HEAD, %g4 53 mov INTRQ_CPU_MONDO_HEAD, %g4
@@ -71,12 +70,12 @@ sun4v_dev_mondo:
71 be,pn %xcc, sun4v_dev_mondo_queue_empty 70 be,pn %xcc, sun4v_dev_mondo_queue_empty
72 nop 71 nop
73 72
74 /* Get &trap_block[smp_processor_id()] into %g3. */ 73 /* Get &trap_block[smp_processor_id()] into %g4. */
75 ldxa [%g0] ASI_SCRATCHPAD, %g3 74 ldxa [%g0] ASI_SCRATCHPAD, %g4
76 sub %g3, TRAP_PER_CPU_FAULT_INFO, %g3 75 sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4
77 76
78 /* Get DEV mondo queue base phys address into %g5. */ 77 /* Get DEV mondo queue base phys address into %g5. */
79 ldx [%g3 + TRAP_PER_CPU_DEV_MONDO_PA], %g5 78 ldx [%g4 + TRAP_PER_CPU_DEV_MONDO_PA], %g5
80 79
81 /* Load IVEC into %g3. */ 80 /* Load IVEC into %g3. */
82 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3 81 ldxa [%g5 + %g2] ASI_PHYS_USE_EC, %g3
@@ -90,8 +89,7 @@ sun4v_dev_mondo:
90 */ 89 */
91 90
92 /* Update queue head pointer, this frees up some registers. */ 91 /* Update queue head pointer, this frees up some registers. */
93 sethi %hi(8192 - 1), %g4 92 lduw [%g4 + TRAP_PER_CPU_DEV_MONDO_QMASK], %g4
94 or %g4, %lo(8192 - 1), %g4
95 and %g2, %g4, %g2 93 and %g2, %g4, %g2
96 94
97 mov INTRQ_DEVICE_MONDO_HEAD, %g4 95 mov INTRQ_DEVICE_MONDO_HEAD, %g4
@@ -143,6 +141,8 @@ sun4v_res_mondo:
143 brnz,pn %g1, sun4v_res_mondo_queue_full 141 brnz,pn %g1, sun4v_res_mondo_queue_full
144 nop 142 nop
145 143
144 lduw [%g3 + TRAP_PER_CPU_RESUM_QMASK], %g4
145
146 /* Remember this entry's offset in %g1. */ 146 /* Remember this entry's offset in %g1. */
147 mov %g2, %g1 147 mov %g2, %g1
148 148
@@ -173,8 +173,6 @@ sun4v_res_mondo:
173 add %g2, 0x08, %g2 173 add %g2, 0x08, %g2
174 174
175 /* Update queue head pointer. */ 175 /* Update queue head pointer. */
176 sethi %hi(8192 - 1), %g4
177 or %g4, %lo(8192 - 1), %g4
178 and %g2, %g4, %g2 176 and %g2, %g4, %g2
179 177
180 mov INTRQ_RESUM_MONDO_HEAD, %g4 178 mov INTRQ_RESUM_MONDO_HEAD, %g4
@@ -254,6 +252,8 @@ sun4v_nonres_mondo:
254 brnz,pn %g1, sun4v_nonres_mondo_queue_full 252 brnz,pn %g1, sun4v_nonres_mondo_queue_full
255 nop 253 nop
256 254
255 lduw [%g3 + TRAP_PER_CPU_NONRESUM_QMASK], %g4
256
257 /* Remember this entry's offset in %g1. */ 257 /* Remember this entry's offset in %g1. */
258 mov %g2, %g1 258 mov %g2, %g1
259 259
@@ -284,8 +284,6 @@ sun4v_nonres_mondo:
284 add %g2, 0x08, %g2 284 add %g2, 0x08, %g2
285 285
286 /* Update queue head pointer. */ 286 /* Update queue head pointer. */
287 sethi %hi(8192 - 1), %g4
288 or %g4, %lo(8192 - 1), %g4
289 and %g2, %g4, %g2 287 and %g2, %g4, %g2
290 288
291 mov INTRQ_NONRESUM_MONDO_HEAD, %g4 289 mov INTRQ_NONRESUM_MONDO_HEAD, %g4
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index 2d63d7689962..a31a0439244f 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -680,22 +680,14 @@ static int starfire_set_time(u32 val)
680 680
681static u32 hypervisor_get_time(void) 681static u32 hypervisor_get_time(void)
682{ 682{
683 register unsigned long func asm("%o5"); 683 unsigned long ret, time;
684 register unsigned long arg0 asm("%o0");
685 register unsigned long arg1 asm("%o1");
686 int retries = 10000; 684 int retries = 10000;
687 685
688retry: 686retry:
689 func = HV_FAST_TOD_GET; 687 ret = sun4v_tod_get(&time);
690 arg0 = 0; 688 if (ret == HV_EOK)
691 arg1 = 0; 689 return time;
692 __asm__ __volatile__("ta %6" 690 if (ret == HV_EWOULDBLOCK) {
693 : "=&r" (func), "=&r" (arg0), "=&r" (arg1)
694 : "0" (func), "1" (arg0), "2" (arg1),
695 "i" (HV_FAST_TRAP));
696 if (arg0 == HV_EOK)
697 return arg1;
698 if (arg0 == HV_EWOULDBLOCK) {
699 if (--retries > 0) { 691 if (--retries > 0) {
700 udelay(100); 692 udelay(100);
701 goto retry; 693 goto retry;
@@ -709,20 +701,14 @@ retry:
709 701
710static int hypervisor_set_time(u32 secs) 702static int hypervisor_set_time(u32 secs)
711{ 703{
712 register unsigned long func asm("%o5"); 704 unsigned long ret;
713 register unsigned long arg0 asm("%o0");
714 int retries = 10000; 705 int retries = 10000;
715 706
716retry: 707retry:
717 func = HV_FAST_TOD_SET; 708 ret = sun4v_tod_set(secs);
718 arg0 = secs; 709 if (ret == HV_EOK)
719 __asm__ __volatile__("ta %4"
720 : "=&r" (func), "=&r" (arg0)
721 : "0" (func), "1" (arg0),
722 "i" (HV_FAST_TRAP));
723 if (arg0 == HV_EOK)
724 return 0; 710 return 0;
725 if (arg0 == HV_EWOULDBLOCK) { 711 if (ret == HV_EWOULDBLOCK) {
726 if (--retries > 0) { 712 if (--retries > 0) {
727 udelay(100); 713 udelay(100);
728 goto retry; 714 goto retry;
@@ -862,7 +848,6 @@ fs_initcall(clock_init);
862static unsigned long sparc64_init_timers(void) 848static unsigned long sparc64_init_timers(void)
863{ 849{
864 struct device_node *dp; 850 struct device_node *dp;
865 struct property *prop;
866 unsigned long clock; 851 unsigned long clock;
867#ifdef CONFIG_SMP 852#ifdef CONFIG_SMP
868 extern void smp_tick_init(void); 853 extern void smp_tick_init(void);
@@ -879,17 +864,15 @@ static unsigned long sparc64_init_timers(void)
879 if (manuf == 0x17 && impl == 0x13) { 864 if (manuf == 0x17 && impl == 0x13) {
880 /* Hummingbird, aka Ultra-IIe */ 865 /* Hummingbird, aka Ultra-IIe */
881 tick_ops = &hbtick_operations; 866 tick_ops = &hbtick_operations;
882 prop = of_find_property(dp, "stick-frequency", NULL); 867 clock = of_getintprop_default(dp, "stick-frequency", 0);
883 } else { 868 } else {
884 tick_ops = &tick_operations; 869 tick_ops = &tick_operations;
885 cpu_find_by_instance(0, &dp, NULL); 870 clock = local_cpu_data().clock_tick;
886 prop = of_find_property(dp, "clock-frequency", NULL);
887 } 871 }
888 } else { 872 } else {
889 tick_ops = &stick_operations; 873 tick_ops = &stick_operations;
890 prop = of_find_property(dp, "stick-frequency", NULL); 874 clock = of_getintprop_default(dp, "stick-frequency", 0);
891 } 875 }
892 clock = *(unsigned int *) prop->value;
893 876
894#ifdef CONFIG_SMP 877#ifdef CONFIG_SMP
895 smp_tick_init(); 878 smp_tick_init();
@@ -1365,6 +1348,7 @@ static int hypervisor_set_rtc_time(struct rtc_time *time)
1365 return hypervisor_set_time(seconds); 1348 return hypervisor_set_time(seconds);
1366} 1349}
1367 1350
1351#ifdef CONFIG_PCI
1368static void bq4802_get_rtc_time(struct rtc_time *time) 1352static void bq4802_get_rtc_time(struct rtc_time *time)
1369{ 1353{
1370 unsigned char val = readb(bq4802_regs + 0x0e); 1354 unsigned char val = readb(bq4802_regs + 0x0e);
@@ -1436,6 +1420,7 @@ static int bq4802_set_rtc_time(struct rtc_time *time)
1436 1420
1437 return 0; 1421 return 0;
1438} 1422}
1423#endif /* CONFIG_PCI */
1439 1424
1440struct mini_rtc_ops { 1425struct mini_rtc_ops {
1441 void (*get_rtc_time)(struct rtc_time *); 1426 void (*get_rtc_time)(struct rtc_time *);
@@ -1452,10 +1437,12 @@ static struct mini_rtc_ops hypervisor_rtc_ops = {
1452 .set_rtc_time = hypervisor_set_rtc_time, 1437 .set_rtc_time = hypervisor_set_rtc_time,
1453}; 1438};
1454 1439
1440#ifdef CONFIG_PCI
1455static struct mini_rtc_ops bq4802_rtc_ops = { 1441static struct mini_rtc_ops bq4802_rtc_ops = {
1456 .get_rtc_time = bq4802_get_rtc_time, 1442 .get_rtc_time = bq4802_get_rtc_time,
1457 .set_rtc_time = bq4802_set_rtc_time, 1443 .set_rtc_time = bq4802_set_rtc_time,
1458}; 1444};
1445#endif /* CONFIG_PCI */
1459 1446
1460static struct mini_rtc_ops *mini_rtc_ops; 1447static struct mini_rtc_ops *mini_rtc_ops;
1461 1448
@@ -1579,8 +1566,10 @@ static int __init rtc_mini_init(void)
1579 mini_rtc_ops = &hypervisor_rtc_ops; 1566 mini_rtc_ops = &hypervisor_rtc_ops;
1580 else if (this_is_starfire) 1567 else if (this_is_starfire)
1581 mini_rtc_ops = &starfire_rtc_ops; 1568 mini_rtc_ops = &starfire_rtc_ops;
1569#ifdef CONFIG_PCI
1582 else if (bq4802_regs) 1570 else if (bq4802_regs)
1583 mini_rtc_ops = &bq4802_rtc_ops; 1571 mini_rtc_ops = &bq4802_rtc_ops;
1572#endif /* CONFIG_PCI */
1584 else 1573 else
1585 return -ENODEV; 1574 return -ENODEV;
1586 1575
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index d0fde36395b4..00a9e3286c83 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -795,8 +795,7 @@ extern unsigned int cheetah_deferred_trap_vector[], cheetah_deferred_trap_vector
795void __init cheetah_ecache_flush_init(void) 795void __init cheetah_ecache_flush_init(void)
796{ 796{
797 unsigned long largest_size, smallest_linesize, order, ver; 797 unsigned long largest_size, smallest_linesize, order, ver;
798 struct device_node *dp; 798 int i, sz;
799 int i, instance, sz;
800 799
801 /* Scan all cpu device tree nodes, note two values: 800 /* Scan all cpu device tree nodes, note two values:
802 * 1) largest E-cache size 801 * 1) largest E-cache size
@@ -805,18 +804,20 @@ void __init cheetah_ecache_flush_init(void)
805 largest_size = 0UL; 804 largest_size = 0UL;
806 smallest_linesize = ~0UL; 805 smallest_linesize = ~0UL;
807 806
808 instance = 0; 807 for (i = 0; i < NR_CPUS; i++) {
809 while (!cpu_find_by_instance(instance, &dp, NULL)) {
810 unsigned long val; 808 unsigned long val;
811 809
812 val = of_getintprop_default(dp, "ecache-size", 810 val = cpu_data(i).ecache_size;
813 (2 * 1024 * 1024)); 811 if (!val)
812 continue;
813
814 if (val > largest_size) 814 if (val > largest_size)
815 largest_size = val; 815 largest_size = val;
816 val = of_getintprop_default(dp, "ecache-line-size", 64); 816
817 val = cpu_data(i).ecache_line_size;
817 if (val < smallest_linesize) 818 if (val < smallest_linesize)
818 smallest_linesize = val; 819 smallest_linesize = val;
819 instance++; 820
820 } 821 }
821 822
822 if (largest_size == 0UL || smallest_linesize == ~0UL) { 823 if (largest_size == 0UL || smallest_linesize == ~0UL) {
@@ -2564,7 +2565,15 @@ void __init trap_init(void)
2564 (TRAP_PER_CPU_TSB_HUGE_TEMP != 2565 (TRAP_PER_CPU_TSB_HUGE_TEMP !=
2565 offsetof(struct trap_per_cpu, tsb_huge_temp)) || 2566 offsetof(struct trap_per_cpu, tsb_huge_temp)) ||
2566 (TRAP_PER_CPU_IRQ_WORKLIST != 2567 (TRAP_PER_CPU_IRQ_WORKLIST !=
2567 offsetof(struct trap_per_cpu, irq_worklist))) 2568 offsetof(struct trap_per_cpu, irq_worklist)) ||
2569 (TRAP_PER_CPU_CPU_MONDO_QMASK !=
2570 offsetof(struct trap_per_cpu, cpu_mondo_qmask)) ||
2571 (TRAP_PER_CPU_DEV_MONDO_QMASK !=
2572 offsetof(struct trap_per_cpu, dev_mondo_qmask)) ||
2573 (TRAP_PER_CPU_RESUM_QMASK !=
2574 offsetof(struct trap_per_cpu, resum_qmask)) ||
2575 (TRAP_PER_CPU_NONRESUM_QMASK !=
2576 offsetof(struct trap_per_cpu, nonresum_qmask)))
2568 trap_per_cpu_offsets_are_bolixed_dave(); 2577 trap_per_cpu_offsets_are_bolixed_dave();
2569 2578
2570 if ((TSB_CONFIG_TSB != 2579 if ((TSB_CONFIG_TSB !=
diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S
index fb648de18a8d..3ad10f3027e4 100644
--- a/arch/sparc64/kernel/vmlinux.lds.S
+++ b/arch/sparc64/kernel/vmlinux.lds.S
@@ -1,5 +1,6 @@
1/* ld script to make UltraLinux kernel */ 1/* ld script to make UltraLinux kernel */
2 2
3#include <asm/page.h>
3#include <asm-generic/vmlinux.lds.h> 4#include <asm-generic/vmlinux.lds.h>
4 5
5OUTPUT_FORMAT("elf64-sparc", "elf64-sparc", "elf64-sparc") 6OUTPUT_FORMAT("elf64-sparc", "elf64-sparc", "elf64-sparc")
@@ -23,7 +24,7 @@ SECTIONS
23 _etext = .; 24 _etext = .;
24 PROVIDE (etext = .); 25 PROVIDE (etext = .);
25 26
26 RODATA 27 RO_DATA(PAGE_SIZE)
27 28
28 .data : 29 .data :
29 { 30 {
@@ -44,7 +45,7 @@ SECTIONS
44 __ex_table : { *(__ex_table) } 45 __ex_table : { *(__ex_table) }
45 __stop___ex_table = .; 46 __stop___ex_table = .;
46 47
47 . = ALIGN(8192); 48 . = ALIGN(PAGE_SIZE);
48 __init_begin = .; 49 __init_begin = .;
49 .init.text : { 50 .init.text : {
50 _sinittext = .; 51 _sinittext = .;
@@ -83,17 +84,17 @@ SECTIONS
83 __sun4v_2insn_patch_end = .; 84 __sun4v_2insn_patch_end = .;
84 85
85#ifdef CONFIG_BLK_DEV_INITRD 86#ifdef CONFIG_BLK_DEV_INITRD
86 . = ALIGN(8192); 87 . = ALIGN(PAGE_SIZE);
87 __initramfs_start = .; 88 __initramfs_start = .;
88 .init.ramfs : { *(.init.ramfs) } 89 .init.ramfs : { *(.init.ramfs) }
89 __initramfs_end = .; 90 __initramfs_end = .;
90#endif 91#endif
91 92
92 . = ALIGN(8192); 93 . = ALIGN(PAGE_SIZE);
93 __per_cpu_start = .; 94 __per_cpu_start = .;
94 .data.percpu : { *(.data.percpu) } 95 .data.percpu : { *(.data.percpu) }
95 __per_cpu_end = .; 96 __per_cpu_end = .;
96 . = ALIGN(8192); 97 . = ALIGN(PAGE_SIZE);
97 __init_end = .; 98 __init_end = .;
98 __bss_start = .; 99 __bss_start = .;
99 .sbss : { *(.sbss) *(.scommon) } 100 .sbss : { *(.sbss) *(.scommon) }
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 6e5b01d779d2..3010227fe243 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -23,6 +23,7 @@
23#include <linux/kprobes.h> 23#include <linux/kprobes.h>
24#include <linux/cache.h> 24#include <linux/cache.h>
25#include <linux/sort.h> 25#include <linux/sort.h>
26#include <linux/percpu.h>
26 27
27#include <asm/head.h> 28#include <asm/head.h>
28#include <asm/system.h> 29#include <asm/system.h>
@@ -43,8 +44,8 @@
43#include <asm/tsb.h> 44#include <asm/tsb.h>
44#include <asm/hypervisor.h> 45#include <asm/hypervisor.h>
45#include <asm/prom.h> 46#include <asm/prom.h>
46 47#include <asm/sstate.h>
47extern void device_scan(void); 48#include <asm/mdesc.h>
48 49
49#define MAX_PHYS_ADDRESS (1UL << 42UL) 50#define MAX_PHYS_ADDRESS (1UL << 42UL)
50#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) 51#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
@@ -60,8 +61,11 @@ unsigned long kern_linear_pte_xor[2] __read_mostly;
60unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)]; 61unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
61 62
62#ifndef CONFIG_DEBUG_PAGEALLOC 63#ifndef CONFIG_DEBUG_PAGEALLOC
63/* A special kernel TSB for 4MB and 256MB linear mappings. */ 64/* A special kernel TSB for 4MB and 256MB linear mappings.
64struct tsb swapper_4m_tsb[KERNEL_TSB4M_NENTRIES]; 65 * Space is allocated for this right after the trap table
66 * in arch/sparc64/kernel/head.S
67 */
68extern struct tsb swapper_4m_tsb[KERNEL_TSB4M_NENTRIES];
65#endif 69#endif
66 70
67#define MAX_BANKS 32 71#define MAX_BANKS 32
@@ -190,12 +194,9 @@ inline void flush_dcache_page_impl(struct page *page)
190} 194}
191 195
192#define PG_dcache_dirty PG_arch_1 196#define PG_dcache_dirty PG_arch_1
193#define PG_dcache_cpu_shift 24UL 197#define PG_dcache_cpu_shift 32UL
194#define PG_dcache_cpu_mask (256UL - 1UL) 198#define PG_dcache_cpu_mask \
195 199 ((1UL<<ilog2(roundup_pow_of_two(NR_CPUS)))-1UL)
196#if NR_CPUS > 256
197#error D-cache dirty tracking and thread_info->cpu need fixing for > 256 cpus
198#endif
199 200
200#define dcache_dirty_cpu(page) \ 201#define dcache_dirty_cpu(page) \
201 (((page)->flags >> PG_dcache_cpu_shift) & PG_dcache_cpu_mask) 202 (((page)->flags >> PG_dcache_cpu_shift) & PG_dcache_cpu_mask)
@@ -557,26 +558,11 @@ static void __init hypervisor_tlb_lock(unsigned long vaddr,
557 unsigned long pte, 558 unsigned long pte,
558 unsigned long mmu) 559 unsigned long mmu)
559{ 560{
560 register unsigned long func asm("%o5"); 561 unsigned long ret = sun4v_mmu_map_perm_addr(vaddr, 0, pte, mmu);
561 register unsigned long arg0 asm("%o0"); 562
562 register unsigned long arg1 asm("%o1"); 563 if (ret != 0) {
563 register unsigned long arg2 asm("%o2");
564 register unsigned long arg3 asm("%o3");
565
566 func = HV_FAST_MMU_MAP_PERM_ADDR;
567 arg0 = vaddr;
568 arg1 = 0;
569 arg2 = pte;
570 arg3 = mmu;
571 __asm__ __volatile__("ta 0x80"
572 : "=&r" (func), "=&r" (arg0),
573 "=&r" (arg1), "=&r" (arg2),
574 "=&r" (arg3)
575 : "0" (func), "1" (arg0), "2" (arg1),
576 "3" (arg2), "4" (arg3));
577 if (arg0 != 0) {
578 prom_printf("hypervisor_tlb_lock[%lx:%lx:%lx:%lx]: " 564 prom_printf("hypervisor_tlb_lock[%lx:%lx:%lx:%lx]: "
579 "errors with %lx\n", vaddr, 0, pte, mmu, arg0); 565 "errors with %lx\n", vaddr, 0, pte, mmu, ret);
580 prom_halt(); 566 prom_halt();
581 } 567 }
582} 568}
@@ -1313,20 +1299,16 @@ static void __init sun4v_ktsb_init(void)
1313 1299
1314void __cpuinit sun4v_ktsb_register(void) 1300void __cpuinit sun4v_ktsb_register(void)
1315{ 1301{
1316 register unsigned long func asm("%o5"); 1302 unsigned long pa, ret;
1317 register unsigned long arg0 asm("%o0");
1318 register unsigned long arg1 asm("%o1");
1319 unsigned long pa;
1320 1303
1321 pa = kern_base + ((unsigned long)&ktsb_descr[0] - KERNBASE); 1304 pa = kern_base + ((unsigned long)&ktsb_descr[0] - KERNBASE);
1322 1305
1323 func = HV_FAST_MMU_TSB_CTX0; 1306 ret = sun4v_mmu_tsb_ctx0(NUM_KTSB_DESCR, pa);
1324 arg0 = NUM_KTSB_DESCR; 1307 if (ret != 0) {
1325 arg1 = pa; 1308 prom_printf("hypervisor_mmu_tsb_ctx0[%lx]: "
1326 __asm__ __volatile__("ta %6" 1309 "errors with %lx\n", pa, ret);
1327 : "=&r" (func), "=&r" (arg0), "=&r" (arg1) 1310 prom_halt();
1328 : "0" (func), "1" (arg0), "2" (arg1), 1311 }
1329 "i" (HV_FAST_TRAP));
1330} 1312}
1331 1313
1332/* paging_init() sets up the page tables */ 1314/* paging_init() sets up the page tables */
@@ -1334,6 +1316,9 @@ void __cpuinit sun4v_ktsb_register(void)
1334extern void cheetah_ecache_flush_init(void); 1316extern void cheetah_ecache_flush_init(void);
1335extern void sun4v_patch_tlb_handlers(void); 1317extern void sun4v_patch_tlb_handlers(void);
1336 1318
1319extern void cpu_probe(void);
1320extern void central_probe(void);
1321
1337static unsigned long last_valid_pfn; 1322static unsigned long last_valid_pfn;
1338pgd_t swapper_pg_dir[2048]; 1323pgd_t swapper_pg_dir[2048];
1339 1324
@@ -1345,9 +1330,24 @@ void __init paging_init(void)
1345 unsigned long end_pfn, pages_avail, shift, phys_base; 1330 unsigned long end_pfn, pages_avail, shift, phys_base;
1346 unsigned long real_end, i; 1331 unsigned long real_end, i;
1347 1332
1333 /* These build time checkes make sure that the dcache_dirty_cpu()
1334 * page->flags usage will work.
1335 *
1336 * When a page gets marked as dcache-dirty, we store the
1337 * cpu number starting at bit 32 in the page->flags. Also,
1338 * functions like clear_dcache_dirty_cpu use the cpu mask
1339 * in 13-bit signed-immediate instruction fields.
1340 */
1341 BUILD_BUG_ON(FLAGS_RESERVED != 32);
1342 BUILD_BUG_ON(SECTIONS_WIDTH + NODES_WIDTH + ZONES_WIDTH +
1343 ilog2(roundup_pow_of_two(NR_CPUS)) > FLAGS_RESERVED);
1344 BUILD_BUG_ON(NR_CPUS > 4096);
1345
1348 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL; 1346 kern_base = (prom_boot_mapping_phys_low >> 22UL) << 22UL;
1349 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE; 1347 kern_size = (unsigned long)&_end - (unsigned long)KERNBASE;
1350 1348
1349 sstate_booting();
1350
1351 /* Invalidate both kernel TSBs. */ 1351 /* Invalidate both kernel TSBs. */
1352 memset(swapper_tsb, 0x40, sizeof(swapper_tsb)); 1352 memset(swapper_tsb, 0x40, sizeof(swapper_tsb));
1353#ifndef CONFIG_DEBUG_PAGEALLOC 1353#ifndef CONFIG_DEBUG_PAGEALLOC
@@ -1416,8 +1416,13 @@ void __init paging_init(void)
1416 1416
1417 kernel_physical_mapping_init(); 1417 kernel_physical_mapping_init();
1418 1418
1419 real_setup_per_cpu_areas();
1420
1419 prom_build_devicetree(); 1421 prom_build_devicetree();
1420 1422
1423 if (tlb_type == hypervisor)
1424 sun4v_mdesc_init();
1425
1421 { 1426 {
1422 unsigned long zones_size[MAX_NR_ZONES]; 1427 unsigned long zones_size[MAX_NR_ZONES];
1423 unsigned long zholes_size[MAX_NR_ZONES]; 1428 unsigned long zholes_size[MAX_NR_ZONES];
@@ -1434,7 +1439,10 @@ void __init paging_init(void)
1434 zholes_size); 1439 zholes_size);
1435 } 1440 }
1436 1441
1437 device_scan(); 1442 prom_printf("Booting Linux...\n");
1443
1444 central_probe();
1445 cpu_probe();
1438} 1446}
1439 1447
1440static void __init taint_real_pages(void) 1448static void __init taint_real_pages(void)
diff --git a/arch/sparc64/prom/misc.c b/arch/sparc64/prom/misc.c
index 0b4213720d43..f3e0c14e9eef 100644
--- a/arch/sparc64/prom/misc.c
+++ b/arch/sparc64/prom/misc.c
@@ -15,6 +15,25 @@
15#include <asm/oplib.h> 15#include <asm/oplib.h>
16#include <asm/system.h> 16#include <asm/system.h>
17 17
18int prom_service_exists(const char *service_name)
19{
20 int err = p1275_cmd("test", P1275_ARG(0, P1275_ARG_IN_STRING) |
21 P1275_INOUT(1, 1), service_name);
22
23 if (err)
24 return 0;
25 return 1;
26}
27
28void prom_sun4v_guest_soft_state(void)
29{
30 const char *svc = "SUNW,soft-state-supported";
31
32 if (!prom_service_exists(svc))
33 return;
34 p1275_cmd(svc, P1275_INOUT(0, 0));
35}
36
18/* Reset and reboot the machine with the command 'bcommand'. */ 37/* Reset and reboot the machine with the command 'bcommand'. */
19void prom_reboot(const char *bcommand) 38void prom_reboot(const char *bcommand)
20{ 39{
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 1336da8bdee1..1ad5111aec38 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -761,3 +761,9 @@ int in_gate_area_no_task(unsigned long addr)
761{ 761{
762 return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END); 762 return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
763} 763}
764
765void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
766{
767 return __alloc_bootmem_core(pgdat->bdata, size,
768 SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
769}