aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-04-14 07:11:02 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-14 07:11:02 -0400
commitac7c5353b189e10cf5dd27399f64f7b013abffc6 (patch)
tree8222d92b774c256d6ec4399c716d76b3f05ddc4b /arch/sparc64
parenta8f75ea70c58546205fb7673be41455b9da5d9a7 (diff)
parent120dd64cacd4fb796bca0acba3665553f1d9ecaa (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/defconfig12
-rw-r--r--arch/sparc64/kernel/cpu.c10
-rw-r--r--arch/sparc64/kernel/entry.S30
-rw-r--r--arch/sparc64/kernel/entry.h196
-rw-r--r--arch/sparc64/kernel/iommu.c20
-rw-r--r--arch/sparc64/kernel/iommu_common.h18
-rw-r--r--arch/sparc64/kernel/irq.c21
-rw-r--r--arch/sparc64/kernel/pci_sun4v.c12
-rw-r--r--arch/sparc64/kernel/ptrace.c222
-rw-r--r--arch/sparc64/kernel/setup.c5
-rw-r--r--arch/sparc64/kernel/signal.c5
-rw-r--r--arch/sparc64/kernel/smp.c3
-rw-r--r--arch/sparc64/kernel/stacktrace.c4
-rw-r--r--arch/sparc64/kernel/sys_sparc.c14
-rw-r--r--arch/sparc64/kernel/systbls.h53
-rw-r--r--arch/sparc64/kernel/time.c66
-rw-r--r--arch/sparc64/kernel/traps.c49
-rw-r--r--arch/sparc64/mm/init.c5
-rw-r--r--arch/sparc64/mm/tlb.c6
19 files changed, 583 insertions, 168 deletions
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 250958d1e3cb..9d4bd2229493 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25-rc1 3# Linux kernel version: 2.6.25-rc3
4# Sun Feb 17 22:44:12 2008 4# Wed Mar 26 04:33:35 2008
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -55,9 +55,11 @@ CONFIG_POSIX_MQUEUE=y
55# CONFIG_IKCONFIG is not set 55# CONFIG_IKCONFIG is not set
56CONFIG_LOG_BUF_SHIFT=18 56CONFIG_LOG_BUF_SHIFT=18
57# CONFIG_CGROUPS is not set 57# CONFIG_CGROUPS is not set
58CONFIG_GROUP_SCHED=y
58CONFIG_FAIR_GROUP_SCHED=y 59CONFIG_FAIR_GROUP_SCHED=y
59CONFIG_FAIR_USER_SCHED=y 60CONFIG_RT_GROUP_SCHED=y
60# CONFIG_FAIR_CGROUP_SCHED is not set 61CONFIG_USER_SCHED=y
62# CONFIG_CGROUP_SCHED is not set
61CONFIG_SYSFS_DEPRECATED=y 63CONFIG_SYSFS_DEPRECATED=y
62CONFIG_RELAY=y 64CONFIG_RELAY=y
63CONFIG_NAMESPACES=y 65CONFIG_NAMESPACES=y
@@ -482,6 +484,7 @@ CONFIG_SCSI_LOWLEVEL=y
482# CONFIG_SCSI_IPS is not set 484# CONFIG_SCSI_IPS is not set
483# CONFIG_SCSI_INITIO is not set 485# CONFIG_SCSI_INITIO is not set
484# CONFIG_SCSI_INIA100 is not set 486# CONFIG_SCSI_INIA100 is not set
487# CONFIG_SCSI_MVSAS is not set
485# CONFIG_SCSI_STEX is not set 488# CONFIG_SCSI_STEX is not set
486# CONFIG_SCSI_SYM53C8XX_2 is not set 489# CONFIG_SCSI_SYM53C8XX_2 is not set
487# CONFIG_SCSI_QLOGIC_1280 is not set 490# CONFIG_SCSI_QLOGIC_1280 is not set
@@ -810,6 +813,7 @@ CONFIG_HWMON=y
810# CONFIG_SENSORS_ADM1031 is not set 813# CONFIG_SENSORS_ADM1031 is not set
811# CONFIG_SENSORS_ADM9240 is not set 814# CONFIG_SENSORS_ADM9240 is not set
812# CONFIG_SENSORS_ADT7470 is not set 815# CONFIG_SENSORS_ADT7470 is not set
816# CONFIG_SENSORS_ADT7473 is not set
813# CONFIG_SENSORS_ATXP1 is not set 817# CONFIG_SENSORS_ATXP1 is not set
814# CONFIG_SENSORS_DS1621 is not set 818# CONFIG_SENSORS_DS1621 is not set
815# CONFIG_SENSORS_I5K_AMB is not set 819# CONFIG_SENSORS_I5K_AMB is not set
diff --git a/arch/sparc64/kernel/cpu.c b/arch/sparc64/kernel/cpu.c
index dd5d28e3d798..0097c08dc600 100644
--- a/arch/sparc64/kernel/cpu.c
+++ b/arch/sparc64/kernel/cpu.c
@@ -15,6 +15,8 @@
15#include <asm/spitfire.h> 15#include <asm/spitfire.h>
16#include <asm/oplib.h> 16#include <asm/oplib.h>
17 17
18#include "entry.h"
19
18DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; 20DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
19 21
20struct cpu_iu_info { 22struct cpu_iu_info {
@@ -65,8 +67,6 @@ static struct cpu_iu_info linux_sparc_chips[] = {
65char *sparc_cpu_type; 67char *sparc_cpu_type;
66char *sparc_fpu_type; 68char *sparc_fpu_type;
67 69
68unsigned int fsr_storage;
69
70static void __init sun4v_cpu_probe(void) 70static void __init sun4v_cpu_probe(void)
71{ 71{
72 switch (sun4v_chip_type) { 72 switch (sun4v_chip_type) {
@@ -94,8 +94,10 @@ void __init cpu_probe(void)
94 unsigned long ver, fpu_vers, manuf, impl, fprs; 94 unsigned long ver, fpu_vers, manuf, impl, fprs;
95 int i; 95 int i;
96 96
97 if (tlb_type == hypervisor) 97 if (tlb_type == hypervisor) {
98 return sun4v_cpu_probe(); 98 sun4v_cpu_probe();
99 return;
100 }
99 101
100 fprs = fprs_read(); 102 fprs = fprs_read();
101 fprs_write(FPRS_FEF); 103 fprs_write(FPRS_FEF);
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
index 6be4d2d2904e..49eca4b1cf25 100644
--- a/arch/sparc64/kernel/entry.S
+++ b/arch/sparc64/kernel/entry.S
@@ -1705,6 +1705,36 @@ __flushw_user:
17052: retl 17052: retl
1706 nop 1706 nop
1707 1707
1708 /* Flush %fp and %i7 to the stack for all register
1709 * windows active inside of the cpu. This allows
1710 * show_stack_trace() to avoid using an expensive
1711 * 'flushw'.
1712 */
1713 .globl stack_trace_flush
1714 .type stack_trace_flush,#function
1715stack_trace_flush:
1716 rdpr %pstate, %o0
1717 wrpr %o0, PSTATE_IE, %pstate
1718
1719 rdpr %cwp, %g1
1720 rdpr %canrestore, %g2
1721 sub %g1, 1, %g3
1722
17231: brz,pn %g2, 2f
1724 sub %g2, 1, %g2
1725 wrpr %g3, %cwp
1726 stx %fp, [%sp + STACK_BIAS + RW_V9_I6]
1727 stx %i7, [%sp + STACK_BIAS + RW_V9_I7]
1728 ba,pt %xcc, 1b
1729 sub %g3, 1, %g3
1730
17312: wrpr %g1, %cwp
1732 wrpr %o0, %pstate
1733
1734 retl
1735 nop
1736 .size stack_trace_flush,.-stack_trace_flush
1737
1708#ifdef CONFIG_SMP 1738#ifdef CONFIG_SMP
1709 .globl hard_smp_processor_id 1739 .globl hard_smp_processor_id
1710hard_smp_processor_id: 1740hard_smp_processor_id:
diff --git a/arch/sparc64/kernel/entry.h b/arch/sparc64/kernel/entry.h
new file mode 100644
index 000000000000..4a91e9c6d31b
--- /dev/null
+++ b/arch/sparc64/kernel/entry.h
@@ -0,0 +1,196 @@
1#ifndef _ENTRY_H
2#define _ENTRY_H
3
4#include <linux/kernel.h>
5#include <linux/types.h>
6#include <linux/init.h>
7
8extern char *sparc_cpu_type;
9extern char *sparc_fpu_type;
10
11extern void __init per_cpu_patch(void);
12extern void __init sun4v_patch(void);
13extern void __init boot_cpu_id_too_large(int cpu);
14extern unsigned int dcache_parity_tl1_occurred;
15extern unsigned int icache_parity_tl1_occurred;
16
17extern asmlinkage void update_perfctrs(void);
18extern asmlinkage void sparc_breakpoint(struct pt_regs *regs);
19extern void timer_interrupt(int irq, struct pt_regs *regs);
20
21extern void do_notify_resume(struct pt_regs *regs,
22 unsigned long orig_i0,
23 int restart_syscall,
24 unsigned long thread_info_flags);
25
26extern asmlinkage void syscall_trace(struct pt_regs *regs,
27 int syscall_exit_p);
28
29extern void bad_trap_tl1(struct pt_regs *regs, long lvl);
30
31extern void do_fpe_common(struct pt_regs *regs);
32extern void do_fpieee(struct pt_regs *regs);
33extern void do_fpother(struct pt_regs *regs);
34extern void do_tof(struct pt_regs *regs);
35extern void do_div0(struct pt_regs *regs);
36extern void do_illegal_instruction(struct pt_regs *regs);
37extern void mem_address_unaligned(struct pt_regs *regs,
38 unsigned long sfar,
39 unsigned long sfsr);
40extern void sun4v_do_mna(struct pt_regs *regs,
41 unsigned long addr,
42 unsigned long type_ctx);
43extern void do_privop(struct pt_regs *regs);
44extern void do_privact(struct pt_regs *regs);
45extern void do_cee(struct pt_regs *regs);
46extern void do_cee_tl1(struct pt_regs *regs);
47extern void do_dae_tl1(struct pt_regs *regs);
48extern void do_iae_tl1(struct pt_regs *regs);
49extern void do_div0_tl1(struct pt_regs *regs);
50extern void do_fpdis_tl1(struct pt_regs *regs);
51extern void do_fpieee_tl1(struct pt_regs *regs);
52extern void do_fpother_tl1(struct pt_regs *regs);
53extern void do_ill_tl1(struct pt_regs *regs);
54extern void do_irq_tl1(struct pt_regs *regs);
55extern void do_lddfmna_tl1(struct pt_regs *regs);
56extern void do_stdfmna_tl1(struct pt_regs *regs);
57extern void do_paw(struct pt_regs *regs);
58extern void do_paw_tl1(struct pt_regs *regs);
59extern void do_vaw(struct pt_regs *regs);
60extern void do_vaw_tl1(struct pt_regs *regs);
61extern void do_tof_tl1(struct pt_regs *regs);
62extern void do_getpsr(struct pt_regs *regs);
63
64extern void spitfire_insn_access_exception(struct pt_regs *regs,
65 unsigned long sfsr,
66 unsigned long sfar);
67extern void spitfire_insn_access_exception_tl1(struct pt_regs *regs,
68 unsigned long sfsr,
69 unsigned long sfar);
70extern void spitfire_data_access_exception(struct pt_regs *regs,
71 unsigned long sfsr,
72 unsigned long sfar);
73extern void spitfire_data_access_exception_tl1(struct pt_regs *regs,
74 unsigned long sfsr,
75 unsigned long sfar);
76extern void spitfire_access_error(struct pt_regs *regs,
77 unsigned long status_encoded,
78 unsigned long afar);
79
80extern void cheetah_fecc_handler(struct pt_regs *regs,
81 unsigned long afsr,
82 unsigned long afar);
83extern void cheetah_cee_handler(struct pt_regs *regs,
84 unsigned long afsr,
85 unsigned long afar);
86extern void cheetah_deferred_handler(struct pt_regs *regs,
87 unsigned long afsr,
88 unsigned long afar);
89extern void cheetah_plus_parity_error(int type, struct pt_regs *regs);
90
91extern void sun4v_insn_access_exception(struct pt_regs *regs,
92 unsigned long addr,
93 unsigned long type_ctx);
94extern void sun4v_insn_access_exception_tl1(struct pt_regs *regs,
95 unsigned long addr,
96 unsigned long type_ctx);
97extern void sun4v_data_access_exception(struct pt_regs *regs,
98 unsigned long addr,
99 unsigned long type_ctx);
100extern void sun4v_data_access_exception_tl1(struct pt_regs *regs,
101 unsigned long addr,
102 unsigned long type_ctx);
103extern void sun4v_resum_error(struct pt_regs *regs,
104 unsigned long offset);
105extern void sun4v_resum_overflow(struct pt_regs *regs);
106extern void sun4v_nonresum_error(struct pt_regs *regs,
107 unsigned long offset);
108extern void sun4v_nonresum_overflow(struct pt_regs *regs);
109
110extern unsigned long sun4v_err_itlb_vaddr;
111extern unsigned long sun4v_err_itlb_ctx;
112extern unsigned long sun4v_err_itlb_pte;
113extern unsigned long sun4v_err_itlb_error;
114
115extern void sun4v_itlb_error_report(struct pt_regs *regs, int tl);
116
117extern unsigned long sun4v_err_dtlb_vaddr;
118extern unsigned long sun4v_err_dtlb_ctx;
119extern unsigned long sun4v_err_dtlb_pte;
120extern unsigned long sun4v_err_dtlb_error;
121
122extern void sun4v_dtlb_error_report(struct pt_regs *regs, int tl);
123extern void hypervisor_tlbop_error(unsigned long err,
124 unsigned long op);
125extern void hypervisor_tlbop_error_xcall(unsigned long err,
126 unsigned long op);
127
128/* WARNING: The error trap handlers in assembly know the precise
129 * layout of the following structure.
130 *
131 * C-level handlers in traps.c use this information to log the
132 * error and then determine how to recover (if possible).
133 */
134struct cheetah_err_info {
135/*0x00*/u64 afsr;
136/*0x08*/u64 afar;
137
138 /* D-cache state */
139/*0x10*/u64 dcache_data[4]; /* The actual data */
140/*0x30*/u64 dcache_index; /* D-cache index */
141/*0x38*/u64 dcache_tag; /* D-cache tag/valid */
142/*0x40*/u64 dcache_utag; /* D-cache microtag */
143/*0x48*/u64 dcache_stag; /* D-cache snooptag */
144
145 /* I-cache state */
146/*0x50*/u64 icache_data[8]; /* The actual insns + predecode */
147/*0x90*/u64 icache_index; /* I-cache index */
148/*0x98*/u64 icache_tag; /* I-cache phys tag */
149/*0xa0*/u64 icache_utag; /* I-cache microtag */
150/*0xa8*/u64 icache_stag; /* I-cache snooptag */
151/*0xb0*/u64 icache_upper; /* I-cache upper-tag */
152/*0xb8*/u64 icache_lower; /* I-cache lower-tag */
153
154 /* E-cache state */
155/*0xc0*/u64 ecache_data[4]; /* 32 bytes from staging registers */
156/*0xe0*/u64 ecache_index; /* E-cache index */
157/*0xe8*/u64 ecache_tag; /* E-cache tag/state */
158
159/*0xf0*/u64 __pad[32 - 30];
160};
161#define CHAFSR_INVALID ((u64)-1L)
162
163/* This is allocated at boot time based upon the largest hardware
164 * cpu ID in the system. We allocate two entries per cpu, one for
165 * TL==0 logging and one for TL >= 1 logging.
166 */
167extern struct cheetah_err_info *cheetah_error_log;
168
169/* UPA nodes send interrupt packet to UltraSparc with first data reg
170 * value low 5 (7 on Starfire) bits holding the IRQ identifier being
171 * delivered. We must translate this into a non-vector IRQ so we can
172 * set the softint on this cpu.
173 *
174 * To make processing these packets efficient and race free we use
175 * an array of irq buckets below. The interrupt vector handler in
176 * entry.S feeds incoming packets into per-cpu pil-indexed lists.
177 *
178 * If you make changes to ino_bucket, please update hand coded assembler
179 * of the vectored interrupt trap handler(s) in entry.S and sun4v_ivec.S
180 */
181struct ino_bucket {
182/*0x00*/unsigned long __irq_chain_pa;
183
184 /* Virtual interrupt number assigned to this INO. */
185/*0x08*/unsigned int __virt_irq;
186/*0x0c*/unsigned int __pad;
187};
188
189extern struct ino_bucket *ivector_table;
190extern unsigned long ivector_table_pa;
191
192extern void handler_irq(int irq, struct pt_regs *regs);
193extern void init_irqwork_curcpu(void);
194extern void __cpuinit sun4v_register_mondo_queues(int this_cpu);
195
196#endif /* _ENTRY_H */
diff --git a/arch/sparc64/kernel/iommu.c b/arch/sparc64/kernel/iommu.c
index fbaab3497bfd..756fa24eeefa 100644
--- a/arch/sparc64/kernel/iommu.c
+++ b/arch/sparc64/kernel/iommu.c
@@ -516,9 +516,11 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
516 unsigned long flags, handle, prot, ctx; 516 unsigned long flags, handle, prot, ctx;
517 dma_addr_t dma_next = 0, dma_addr; 517 dma_addr_t dma_next = 0, dma_addr;
518 unsigned int max_seg_size; 518 unsigned int max_seg_size;
519 unsigned long seg_boundary_size;
519 int outcount, incount, i; 520 int outcount, incount, i;
520 struct strbuf *strbuf; 521 struct strbuf *strbuf;
521 struct iommu *iommu; 522 struct iommu *iommu;
523 unsigned long base_shift;
522 524
523 BUG_ON(direction == DMA_NONE); 525 BUG_ON(direction == DMA_NONE);
524 526
@@ -549,8 +551,11 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
549 outs->dma_length = 0; 551 outs->dma_length = 0;
550 552
551 max_seg_size = dma_get_max_seg_size(dev); 553 max_seg_size = dma_get_max_seg_size(dev);
554 seg_boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
555 IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
556 base_shift = iommu->page_table_map_base >> IO_PAGE_SHIFT;
552 for_each_sg(sglist, s, nelems, i) { 557 for_each_sg(sglist, s, nelems, i) {
553 unsigned long paddr, npages, entry, slen; 558 unsigned long paddr, npages, entry, out_entry = 0, slen;
554 iopte_t *base; 559 iopte_t *base;
555 560
556 slen = s->length; 561 slen = s->length;
@@ -593,7 +598,9 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
593 * - allocated dma_addr isn't contiguous to previous allocation 598 * - allocated dma_addr isn't contiguous to previous allocation
594 */ 599 */
595 if ((dma_addr != dma_next) || 600 if ((dma_addr != dma_next) ||
596 (outs->dma_length + s->length > max_seg_size)) { 601 (outs->dma_length + s->length > max_seg_size) ||
602 (is_span_boundary(out_entry, base_shift,
603 seg_boundary_size, outs, s))) {
597 /* Can't merge: create a new segment */ 604 /* Can't merge: create a new segment */
598 segstart = s; 605 segstart = s;
599 outcount++; 606 outcount++;
@@ -607,6 +614,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
607 /* This is a new segment, fill entries */ 614 /* This is a new segment, fill entries */
608 outs->dma_address = dma_addr; 615 outs->dma_address = dma_addr;
609 outs->dma_length = slen; 616 outs->dma_length = slen;
617 out_entry = entry;
610 } 618 }
611 619
612 /* Calculate next page pointer for contiguous check */ 620 /* Calculate next page pointer for contiguous check */
@@ -626,7 +634,7 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
626iommu_map_failed: 634iommu_map_failed:
627 for_each_sg(sglist, s, nelems, i) { 635 for_each_sg(sglist, s, nelems, i) {
628 if (s->dma_length != 0) { 636 if (s->dma_length != 0) {
629 unsigned long vaddr, npages, entry, i; 637 unsigned long vaddr, npages, entry, j;
630 iopte_t *base; 638 iopte_t *base;
631 639
632 vaddr = s->dma_address & IO_PAGE_MASK; 640 vaddr = s->dma_address & IO_PAGE_MASK;
@@ -637,8 +645,8 @@ iommu_map_failed:
637 >> IO_PAGE_SHIFT; 645 >> IO_PAGE_SHIFT;
638 base = iommu->page_table + entry; 646 base = iommu->page_table + entry;
639 647
640 for (i = 0; i < npages; i++) 648 for (j = 0; j < npages; j++)
641 iopte_make_dummy(iommu, base + i); 649 iopte_make_dummy(iommu, base + j);
642 650
643 s->dma_address = DMA_ERROR_CODE; 651 s->dma_address = DMA_ERROR_CODE;
644 s->dma_length = 0; 652 s->dma_length = 0;
@@ -803,7 +811,7 @@ static void dma_4u_sync_sg_for_cpu(struct device *dev,
803 spin_unlock_irqrestore(&iommu->lock, flags); 811 spin_unlock_irqrestore(&iommu->lock, flags);
804} 812}
805 813
806const struct dma_ops sun4u_dma_ops = { 814static const struct dma_ops sun4u_dma_ops = {
807 .alloc_coherent = dma_4u_alloc_coherent, 815 .alloc_coherent = dma_4u_alloc_coherent,
808 .free_coherent = dma_4u_free_coherent, 816 .free_coherent = dma_4u_free_coherent,
809 .map_single = dma_4u_map_single, 817 .map_single = dma_4u_map_single,
diff --git a/arch/sparc64/kernel/iommu_common.h b/arch/sparc64/kernel/iommu_common.h
index 0713bd58499c..f3575a614fa2 100644
--- a/arch/sparc64/kernel/iommu_common.h
+++ b/arch/sparc64/kernel/iommu_common.h
@@ -12,6 +12,7 @@
12#include <linux/mm.h> 12#include <linux/mm.h>
13#include <linux/scatterlist.h> 13#include <linux/scatterlist.h>
14#include <linux/device.h> 14#include <linux/device.h>
15#include <linux/iommu-helper.h>
15 16
16#include <asm/iommu.h> 17#include <asm/iommu.h>
17#include <asm/scatterlist.h> 18#include <asm/scatterlist.h>
@@ -45,17 +46,16 @@ static inline unsigned long iommu_num_pages(unsigned long vaddr,
45 return npages; 46 return npages;
46} 47}
47 48
48static inline unsigned long calc_npages(struct scatterlist *sglist, int nelems) 49static inline int is_span_boundary(unsigned long entry,
50 unsigned long shift,
51 unsigned long boundary_size,
52 struct scatterlist *outs,
53 struct scatterlist *sg)
49{ 54{
50 unsigned long i, npages = 0; 55 unsigned long paddr = SG_ENT_PHYS_ADDRESS(outs);
51 struct scatterlist *sg; 56 int nr = iommu_num_pages(paddr, outs->dma_length + sg->length);
52 57
53 for_each_sg(sglist, sg, nelems, i) { 58 return iommu_is_span_boundary(entry, nr, shift, boundary_size);
54 unsigned long paddr = SG_ENT_PHYS_ADDRESS(sg);
55 npages += iommu_num_pages(paddr, sg->length);
56 }
57
58 return npages;
59} 59}
60 60
61extern unsigned long iommu_range_alloc(struct device *dev, 61extern unsigned long iommu_range_alloc(struct device *dev,
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index 5ec06c8c7fea..eb88bd6e674e 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -44,27 +44,10 @@
44#include <asm/hypervisor.h> 44#include <asm/hypervisor.h>
45#include <asm/cacheflush.h> 45#include <asm/cacheflush.h>
46 46
47/* UPA nodes send interrupt packet to UltraSparc with first data reg 47#include "entry.h"
48 * value low 5 (7 on Starfire) bits holding the IRQ identifier being
49 * delivered. We must translate this into a non-vector IRQ so we can
50 * set the softint on this cpu.
51 *
52 * To make processing these packets efficient and race free we use
53 * an array of irq buckets below. The interrupt vector handler in
54 * entry.S feeds incoming packets into per-cpu pil-indexed lists.
55 *
56 * If you make changes to ino_bucket, please update hand coded assembler
57 * of the vectored interrupt trap handler(s) in entry.S and sun4v_ivec.S
58 */
59struct ino_bucket {
60/*0x00*/unsigned long __irq_chain_pa;
61
62 /* Virtual interrupt number assigned to this INO. */
63/*0x08*/unsigned int __virt_irq;
64/*0x0c*/unsigned int __pad;
65};
66 48
67#define NUM_IVECS (IMAP_INR + 1) 49#define NUM_IVECS (IMAP_INR + 1)
50
68struct ino_bucket *ivector_table; 51struct ino_bucket *ivector_table;
69unsigned long ivector_table_pa; 52unsigned long ivector_table_pa;
70 53
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c
index ddca6c6c0b49..01839706bd52 100644
--- a/arch/sparc64/kernel/pci_sun4v.c
+++ b/arch/sparc64/kernel/pci_sun4v.c
@@ -335,8 +335,10 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
335 unsigned long flags, handle, prot; 335 unsigned long flags, handle, prot;
336 dma_addr_t dma_next = 0, dma_addr; 336 dma_addr_t dma_next = 0, dma_addr;
337 unsigned int max_seg_size; 337 unsigned int max_seg_size;
338 unsigned long seg_boundary_size;
338 int outcount, incount, i; 339 int outcount, incount, i;
339 struct iommu *iommu; 340 struct iommu *iommu;
341 unsigned long base_shift;
340 long err; 342 long err;
341 343
342 BUG_ON(direction == DMA_NONE); 344 BUG_ON(direction == DMA_NONE);
@@ -362,8 +364,11 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
362 iommu_batch_start(dev, prot, ~0UL); 364 iommu_batch_start(dev, prot, ~0UL);
363 365
364 max_seg_size = dma_get_max_seg_size(dev); 366 max_seg_size = dma_get_max_seg_size(dev);
367 seg_boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
368 IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
369 base_shift = iommu->page_table_map_base >> IO_PAGE_SHIFT;
365 for_each_sg(sglist, s, nelems, i) { 370 for_each_sg(sglist, s, nelems, i) {
366 unsigned long paddr, npages, entry, slen; 371 unsigned long paddr, npages, entry, out_entry = 0, slen;
367 372
368 slen = s->length; 373 slen = s->length;
369 /* Sanity check */ 374 /* Sanity check */
@@ -406,7 +411,9 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
406 * - allocated dma_addr isn't contiguous to previous allocation 411 * - allocated dma_addr isn't contiguous to previous allocation
407 */ 412 */
408 if ((dma_addr != dma_next) || 413 if ((dma_addr != dma_next) ||
409 (outs->dma_length + s->length > max_seg_size)) { 414 (outs->dma_length + s->length > max_seg_size) ||
415 (is_span_boundary(out_entry, base_shift,
416 seg_boundary_size, outs, s))) {
410 /* Can't merge: create a new segment */ 417 /* Can't merge: create a new segment */
411 segstart = s; 418 segstart = s;
412 outcount++; 419 outcount++;
@@ -420,6 +427,7 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
420 /* This is a new segment, fill entries */ 427 /* This is a new segment, fill entries */
421 outs->dma_address = dma_addr; 428 outs->dma_address = dma_addr;
422 outs->dma_length = slen; 429 outs->dma_length = slen;
430 out_entry = entry;
423 } 431 }
424 432
425 /* Calculate next page pointer for contiguous check */ 433 /* Calculate next page pointer for contiguous check */
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index 9a1ba1fe859d..e9fc0aa2da38 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -35,6 +35,9 @@
35#include <asm/spitfire.h> 35#include <asm/spitfire.h>
36#include <asm/page.h> 36#include <asm/page.h>
37#include <asm/cpudata.h> 37#include <asm/cpudata.h>
38#include <asm/cacheflush.h>
39
40#include "entry.h"
38 41
39/* #define ALLOW_INIT_TRACING */ 42/* #define ALLOW_INIT_TRACING */
40 43
@@ -67,6 +70,8 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
67 if (tlb_type == hypervisor) 70 if (tlb_type == hypervisor)
68 return; 71 return;
69 72
73 preempt_disable();
74
70#ifdef DCACHE_ALIASING_POSSIBLE 75#ifdef DCACHE_ALIASING_POSSIBLE
71 /* If bit 13 of the kernel address we used to access the 76 /* If bit 13 of the kernel address we used to access the
72 * user page is the same as the virtual address that page 77 * user page is the same as the virtual address that page
@@ -105,6 +110,87 @@ void flush_ptrace_access(struct vm_area_struct *vma, struct page *page,
105 for (; start < end; start += icache_line_size) 110 for (; start < end; start += icache_line_size)
106 flushi(start); 111 flushi(start);
107 } 112 }
113
114 preempt_enable();
115}
116
117static int get_from_target(struct task_struct *target, unsigned long uaddr,
118 void *kbuf, int len)
119{
120 if (target == current) {
121 if (copy_from_user(kbuf, (void __user *) uaddr, len))
122 return -EFAULT;
123 } else {
124 int len2 = access_process_vm(target, uaddr, kbuf, len, 0);
125 if (len2 != len)
126 return -EFAULT;
127 }
128 return 0;
129}
130
131static int set_to_target(struct task_struct *target, unsigned long uaddr,
132 void *kbuf, int len)
133{
134 if (target == current) {
135 if (copy_to_user((void __user *) uaddr, kbuf, len))
136 return -EFAULT;
137 } else {
138 int len2 = access_process_vm(target, uaddr, kbuf, len, 1);
139 if (len2 != len)
140 return -EFAULT;
141 }
142 return 0;
143}
144
145static int regwindow64_get(struct task_struct *target,
146 const struct pt_regs *regs,
147 struct reg_window *wbuf)
148{
149 unsigned long rw_addr = regs->u_regs[UREG_I6];
150
151 if (test_tsk_thread_flag(current, TIF_32BIT)) {
152 struct reg_window32 win32;
153 int i;
154
155 if (get_from_target(target, rw_addr, &win32, sizeof(win32)))
156 return -EFAULT;
157 for (i = 0; i < 8; i++)
158 wbuf->locals[i] = win32.locals[i];
159 for (i = 0; i < 8; i++)
160 wbuf->ins[i] = win32.ins[i];
161 } else {
162 rw_addr += STACK_BIAS;
163 if (get_from_target(target, rw_addr, wbuf, sizeof(*wbuf)))
164 return -EFAULT;
165 }
166
167 return 0;
168}
169
170static int regwindow64_set(struct task_struct *target,
171 const struct pt_regs *regs,
172 struct reg_window *wbuf)
173{
174 unsigned long rw_addr = regs->u_regs[UREG_I6];
175
176 if (test_tsk_thread_flag(current, TIF_32BIT)) {
177 struct reg_window32 win32;
178 int i;
179
180 for (i = 0; i < 8; i++)
181 win32.locals[i] = wbuf->locals[i];
182 for (i = 0; i < 8; i++)
183 win32.ins[i] = wbuf->ins[i];
184
185 if (set_to_target(target, rw_addr, &win32, sizeof(win32)))
186 return -EFAULT;
187 } else {
188 rw_addr += STACK_BIAS;
189 if (set_to_target(target, rw_addr, wbuf, sizeof(*wbuf)))
190 return -EFAULT;
191 }
192
193 return 0;
108} 194}
109 195
110enum sparc_regset { 196enum sparc_regset {
@@ -126,16 +212,13 @@ static int genregs64_get(struct task_struct *target,
126 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 212 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
127 regs->u_regs, 213 regs->u_regs,
128 0, 16 * sizeof(u64)); 214 0, 16 * sizeof(u64));
129 if (!ret) { 215 if (!ret && count && pos < (32 * sizeof(u64))) {
130 unsigned long __user *reg_window = (unsigned long __user *) 216 struct reg_window window;
131 (regs->u_regs[UREG_I6] + STACK_BIAS);
132 unsigned long window[16];
133 217
134 if (copy_from_user(window, reg_window, sizeof(window))) 218 if (regwindow64_get(target, regs, &window))
135 return -EFAULT; 219 return -EFAULT;
136
137 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 220 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
138 window, 221 &window,
139 16 * sizeof(u64), 222 16 * sizeof(u64),
140 32 * sizeof(u64)); 223 32 * sizeof(u64));
141 } 224 }
@@ -157,10 +240,11 @@ static int genregs64_get(struct task_struct *target,
157 36 * sizeof(u64)); 240 36 * sizeof(u64));
158 } 241 }
159 242
160 if (!ret) 243 if (!ret) {
161 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, 244 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
162 36 * sizeof(u64), -1); 245 36 * sizeof(u64), -1);
163 246
247 }
164 return ret; 248 return ret;
165} 249}
166 250
@@ -178,20 +262,19 @@ static int genregs64_set(struct task_struct *target,
178 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 262 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
179 regs->u_regs, 263 regs->u_regs,
180 0, 16 * sizeof(u64)); 264 0, 16 * sizeof(u64));
181 if (!ret && count > 0) { 265 if (!ret && count && pos < (32 * sizeof(u64))) {
182 unsigned long __user *reg_window = (unsigned long __user *) 266 struct reg_window window;
183 (regs->u_regs[UREG_I6] + STACK_BIAS);
184 unsigned long window[16];
185 267
186 if (copy_from_user(window, reg_window, sizeof(window))) 268 if (regwindow64_get(target, regs, &window))
187 return -EFAULT; 269 return -EFAULT;
188 270
189 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 271 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
190 window, 272 &window,
191 16 * sizeof(u64), 273 16 * sizeof(u64),
192 32 * sizeof(u64)); 274 32 * sizeof(u64));
275
193 if (!ret && 276 if (!ret &&
194 copy_to_user(reg_window, window, sizeof(window))) 277 regwindow64_set(target, regs, &window))
195 return -EFAULT; 278 return -EFAULT;
196 } 279 }
197 280
@@ -382,6 +465,7 @@ static const struct user_regset_view user_sparc64_view = {
382 .regsets = sparc64_regsets, .n = ARRAY_SIZE(sparc64_regsets) 465 .regsets = sparc64_regsets, .n = ARRAY_SIZE(sparc64_regsets)
383}; 466};
384 467
468#ifdef CONFIG_COMPAT
385static int genregs32_get(struct task_struct *target, 469static int genregs32_get(struct task_struct *target,
386 const struct user_regset *regset, 470 const struct user_regset *regset,
387 unsigned int pos, unsigned int count, 471 unsigned int pos, unsigned int count,
@@ -404,9 +488,22 @@ static int genregs32_get(struct task_struct *target,
404 *k++ = regs->u_regs[pos++]; 488 *k++ = regs->u_regs[pos++];
405 489
406 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; 490 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
407 for (; count > 0 && pos < 32; count--) { 491 if (target == current) {
408 if (get_user(*k++, &reg_window[pos++])) 492 for (; count > 0 && pos < 32; count--) {
409 return -EFAULT; 493 if (get_user(*k++, &reg_window[pos++]))
494 return -EFAULT;
495 }
496 } else {
497 for (; count > 0 && pos < 32; count--) {
498 if (access_process_vm(target,
499 (unsigned long)
500 &reg_window[pos],
501 k, sizeof(*k), 0)
502 != sizeof(*k))
503 return -EFAULT;
504 k++;
505 pos++;
506 }
410 } 507 }
411 } else { 508 } else {
412 for (; count > 0 && pos < 16; count--) { 509 for (; count > 0 && pos < 16; count--) {
@@ -415,10 +512,28 @@ static int genregs32_get(struct task_struct *target,
415 } 512 }
416 513
417 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; 514 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
418 for (; count > 0 && pos < 32; count--) { 515 if (target == current) {
419 if (get_user(reg, &reg_window[pos++]) || 516 for (; count > 0 && pos < 32; count--) {
420 put_user(reg, u++)) 517 if (get_user(reg, &reg_window[pos++]) ||
421 return -EFAULT; 518 put_user(reg, u++))
519 return -EFAULT;
520 }
521 } else {
522 for (; count > 0 && pos < 32; count--) {
523 if (access_process_vm(target,
524 (unsigned long)
525 &reg_window[pos],
526 &reg, sizeof(reg), 0)
527 != sizeof(reg))
528 return -EFAULT;
529 if (access_process_vm(target,
530 (unsigned long) u,
531 &reg, sizeof(reg), 1)
532 != sizeof(reg))
533 return -EFAULT;
534 pos++;
535 u++;
536 }
422 } 537 }
423 } 538 }
424 while (count > 0) { 539 while (count > 0) {
@@ -480,9 +595,23 @@ static int genregs32_set(struct task_struct *target,
480 regs->u_regs[pos++] = *k++; 595 regs->u_regs[pos++] = *k++;
481 596
482 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; 597 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
483 for (; count > 0 && pos < 32; count--) { 598 if (target == current) {
484 if (put_user(*k++, &reg_window[pos++])) 599 for (; count > 0 && pos < 32; count--) {
485 return -EFAULT; 600 if (put_user(*k++, &reg_window[pos++]))
601 return -EFAULT;
602 }
603 } else {
604 for (; count > 0 && pos < 32; count--) {
605 if (access_process_vm(target,
606 (unsigned long)
607 &reg_window[pos],
608 (void *) k,
609 sizeof(*k), 1)
610 != sizeof(*k))
611 return -EFAULT;
612 k++;
613 pos++;
614 }
486 } 615 }
487 } else { 616 } else {
488 for (; count > 0 && pos < 16; count--) { 617 for (; count > 0 && pos < 16; count--) {
@@ -492,10 +621,29 @@ static int genregs32_set(struct task_struct *target,
492 } 621 }
493 622
494 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6]; 623 reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
495 for (; count > 0 && pos < 32; count--) { 624 if (target == current) {
496 if (get_user(reg, u++) || 625 for (; count > 0 && pos < 32; count--) {
497 put_user(reg, &reg_window[pos++])) 626 if (get_user(reg, u++) ||
498 return -EFAULT; 627 put_user(reg, &reg_window[pos++]))
628 return -EFAULT;
629 }
630 } else {
631 for (; count > 0 && pos < 32; count--) {
632 if (access_process_vm(target,
633 (unsigned long)
634 u,
635 &reg, sizeof(reg), 0)
636 != sizeof(reg))
637 return -EFAULT;
638 if (access_process_vm(target,
639 (unsigned long)
640 &reg_window[pos],
641 &reg, sizeof(reg), 1)
642 != sizeof(reg))
643 return -EFAULT;
644 pos++;
645 u++;
646 }
499 } 647 }
500 } 648 }
501 while (count > 0) { 649 while (count > 0) {
@@ -676,14 +824,18 @@ static const struct user_regset_view user_sparc32_view = {
676 .name = "sparc", .e_machine = EM_SPARC, 824 .name = "sparc", .e_machine = EM_SPARC,
677 .regsets = sparc32_regsets, .n = ARRAY_SIZE(sparc32_regsets) 825 .regsets = sparc32_regsets, .n = ARRAY_SIZE(sparc32_regsets)
678}; 826};
827#endif /* CONFIG_COMPAT */
679 828
680const struct user_regset_view *task_user_regset_view(struct task_struct *task) 829const struct user_regset_view *task_user_regset_view(struct task_struct *task)
681{ 830{
831#ifdef CONFIG_COMPAT
682 if (test_tsk_thread_flag(task, TIF_32BIT)) 832 if (test_tsk_thread_flag(task, TIF_32BIT))
683 return &user_sparc32_view; 833 return &user_sparc32_view;
834#endif
684 return &user_sparc64_view; 835 return &user_sparc64_view;
685} 836}
686 837
838#ifdef CONFIG_COMPAT
687struct compat_fps { 839struct compat_fps {
688 unsigned int regs[32]; 840 unsigned int regs[32];
689 unsigned int fsr; 841 unsigned int fsr;
@@ -699,7 +851,7 @@ struct compat_fps {
699long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 851long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
700 compat_ulong_t caddr, compat_ulong_t cdata) 852 compat_ulong_t caddr, compat_ulong_t cdata)
701{ 853{
702 const struct user_regset_view *view = task_user_regset_view(child); 854 const struct user_regset_view *view = task_user_regset_view(current);
703 compat_ulong_t caddr2 = task_pt_regs(current)->u_regs[UREG_I4]; 855 compat_ulong_t caddr2 = task_pt_regs(current)->u_regs[UREG_I4];
704 struct pt_regs32 __user *pregs; 856 struct pt_regs32 __user *pregs;
705 struct compat_fps __user *fps; 857 struct compat_fps __user *fps;
@@ -798,6 +950,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
798 950
799 return ret; 951 return ret;
800} 952}
953#endif /* CONFIG_COMPAT */
801 954
802struct fps { 955struct fps {
803 unsigned int regs[64]; 956 unsigned int regs[64];
@@ -806,12 +959,15 @@ struct fps {
806 959
807long arch_ptrace(struct task_struct *child, long request, long addr, long data) 960long arch_ptrace(struct task_struct *child, long request, long addr, long data)
808{ 961{
809 const struct user_regset_view *view = task_user_regset_view(child); 962 const struct user_regset_view *view = task_user_regset_view(current);
810 struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
811 unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; 963 unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4];
812 struct fps __user *fps = (struct fps __user *) addr; 964 struct pt_regs __user *pregs;
965 struct fps __user *fps;
813 int ret; 966 int ret;
814 967
968 pregs = (struct pt_regs __user *) (unsigned long) addr;
969 fps = (struct fps __user *) (unsigned long) addr;
970
815 switch (request) { 971 switch (request) {
816 case PTRACE_PEEKUSR: 972 case PTRACE_PEEKUSR:
817 ret = (addr != 0) ? -EIO : 0; 973 ret = (addr != 0) ? -EIO : 0;
diff --git a/arch/sparc64/kernel/setup.c b/arch/sparc64/kernel/setup.c
index d036dbe72864..6acb4c51cfe4 100644
--- a/arch/sparc64/kernel/setup.c
+++ b/arch/sparc64/kernel/setup.c
@@ -51,6 +51,8 @@
51#include <net/ipconfig.h> 51#include <net/ipconfig.h>
52#endif 52#endif
53 53
54#include "entry.h"
55
54/* Used to synchronize accesses to NatSemi SUPER I/O chip configure 56/* Used to synchronize accesses to NatSemi SUPER I/O chip configure
55 * operations in asm/ns87303.h 57 * operations in asm/ns87303.h
56 */ 58 */
@@ -335,9 +337,6 @@ void __init setup_arch(char **cmdline_p)
335 337
336/* BUFFER is PAGE_SIZE bytes long. */ 338/* BUFFER is PAGE_SIZE bytes long. */
337 339
338extern char *sparc_cpu_type;
339extern char *sparc_fpu_type;
340
341extern void smp_info(struct seq_file *); 340extern void smp_info(struct seq_file *);
342extern void smp_bogo(struct seq_file *); 341extern void smp_bogo(struct seq_file *);
343extern void mmu_info(struct seq_file *); 342extern void mmu_info(struct seq_file *);
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index fb13775b3682..9d51956e8e2f 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -32,6 +32,9 @@
32#include <asm/siginfo.h> 32#include <asm/siginfo.h>
33#include <asm/visasm.h> 33#include <asm/visasm.h>
34 34
35#include "entry.h"
36#include "systbls.h"
37
35#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 38#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
36 39
37/* {set, get}context() needed for 64-bit SparcLinux userland. */ 40/* {set, get}context() needed for 64-bit SparcLinux userland. */
@@ -354,7 +357,7 @@ static int invalid_frame_pointer(void __user *fp, int fplen)
354static inline int 357static inline int
355save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu) 358save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
356{ 359{
357 unsigned long *fpregs = (unsigned long *)(regs+1); 360 unsigned long *fpregs = current_thread_info()->fpregs;
358 unsigned long fprs; 361 unsigned long fprs;
359 int err = 0; 362 int err = 0;
360 363
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 5a1126b363a4..59f020d69d4c 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -1,6 +1,6 @@
1/* smp.c: Sparc64 SMP support. 1/* smp.c: Sparc64 SMP support.
2 * 2 *
3 * Copyright (C) 1997, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1997, 2007, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -30,6 +30,7 @@
30#include <asm/cpudata.h> 30#include <asm/cpudata.h>
31#include <asm/hvtramp.h> 31#include <asm/hvtramp.h>
32#include <asm/io.h> 32#include <asm/io.h>
33#include <asm/timer.h>
33 34
34#include <asm/irq.h> 35#include <asm/irq.h>
35#include <asm/irq_regs.h> 36#include <asm/irq_regs.h>
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index 47f92a59be18..84d39e873e88 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -2,13 +2,15 @@
2#include <linux/stacktrace.h> 2#include <linux/stacktrace.h>
3#include <linux/thread_info.h> 3#include <linux/thread_info.h>
4#include <asm/ptrace.h> 4#include <asm/ptrace.h>
5#include <asm/stacktrace.h>
5 6
6void save_stack_trace(struct stack_trace *trace) 7void save_stack_trace(struct stack_trace *trace)
7{ 8{
8 unsigned long ksp, fp, thread_base; 9 unsigned long ksp, fp, thread_base;
9 struct thread_info *tp = task_thread_info(current); 10 struct thread_info *tp = task_thread_info(current);
10 11
11 flushw_all(); 12 stack_trace_flush();
13
12 __asm__ __volatile__( 14 __asm__ __volatile__(
13 "mov %%fp, %0" 15 "mov %%fp, %0"
14 : "=r" (ksp) 16 : "=r" (ksp)
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c
index 134d801579f9..f952745d0f3d 100644
--- a/arch/sparc64/kernel/sys_sparc.c
+++ b/arch/sparc64/kernel/sys_sparc.c
@@ -1,5 +1,4 @@
1/* $Id: sys_sparc.c,v 1.57 2002/02/09 19:49:30 davem Exp $ 1/* linux/arch/sparc64/kernel/sys_sparc.c
2 * linux/arch/sparc64/kernel/sys_sparc.c
3 * 2 *
4 * This file contains various random system calls that 3 * This file contains various random system calls that
5 * have a non-standard calling sequence on the Linux/sparc 4 * have a non-standard calling sequence on the Linux/sparc
@@ -30,6 +29,9 @@
30#include <asm/perfctr.h> 29#include <asm/perfctr.h>
31#include <asm/unistd.h> 30#include <asm/unistd.h>
32 31
32#include "entry.h"
33#include "systbls.h"
34
33/* #define DEBUG_UNIMP_SYSCALL */ 35/* #define DEBUG_UNIMP_SYSCALL */
34 36
35asmlinkage unsigned long sys_getpagesize(void) 37asmlinkage unsigned long sys_getpagesize(void)
@@ -445,7 +447,8 @@ asmlinkage long sys_ipc(unsigned int call, int first, unsigned long second,
445 goto out; 447 goto out;
446 case SEMTIMEDOP: 448 case SEMTIMEDOP:
447 err = sys_semtimedop(first, ptr, (unsigned)second, 449 err = sys_semtimedop(first, ptr, (unsigned)second,
448 (const struct timespec __user *) fifth); 450 (const struct timespec __user *)
451 (unsigned long) fifth);
449 goto out; 452 goto out;
450 case SEMGET: 453 case SEMGET:
451 err = sys_semget(first, (int)second, (int)third); 454 err = sys_semget(first, (int)second, (int)third);
@@ -788,7 +791,7 @@ asmlinkage long sys_utrap_install(utrap_entry_t type,
788 } else { 791 } else {
789 if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p && 792 if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p &&
790 current_thread_info()->utraps[0] > 1) { 793 current_thread_info()->utraps[0] > 1) {
791 long *p = current_thread_info()->utraps; 794 unsigned long *p = current_thread_info()->utraps;
792 795
793 current_thread_info()->utraps = 796 current_thread_info()->utraps =
794 kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), 797 kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
@@ -816,7 +819,8 @@ asmlinkage long sys_utrap_install(utrap_entry_t type,
816 return 0; 819 return 0;
817} 820}
818 821
819long sparc_memory_ordering(unsigned long model, struct pt_regs *regs) 822asmlinkage long sparc_memory_ordering(unsigned long model,
823 struct pt_regs *regs)
820{ 824{
821 if (model >= 3) 825 if (model >= 3)
822 return -EINVAL; 826 return -EINVAL;
diff --git a/arch/sparc64/kernel/systbls.h b/arch/sparc64/kernel/systbls.h
new file mode 100644
index 000000000000..8a0d20a35d0c
--- /dev/null
+++ b/arch/sparc64/kernel/systbls.h
@@ -0,0 +1,53 @@
1#ifndef _SYSTBLS_H
2#define _SYSTBLS_H
3
4#include <linux/kernel.h>
5#include <linux/types.h>
6#include <linux/utsname.h>
7#include <asm/utrap.h>
8#include <asm/signal.h>
9
10extern asmlinkage unsigned long sys_getpagesize(void);
11extern asmlinkage unsigned long sparc_brk(unsigned long brk);
12extern asmlinkage long sparc_pipe(struct pt_regs *regs);
13extern asmlinkage long sys_ipc(unsigned int call, int first,
14 unsigned long second,
15 unsigned long third,
16 void __user *ptr, long fifth);
17extern asmlinkage long sparc64_newuname(struct new_utsname __user *name);
18extern asmlinkage long sparc64_personality(unsigned long personality);
19extern asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
20 unsigned long prot, unsigned long flags,
21 unsigned long fd, unsigned long off);
22extern asmlinkage long sys64_munmap(unsigned long addr, size_t len);
23extern asmlinkage unsigned long sys64_mremap(unsigned long addr,
24 unsigned long old_len,
25 unsigned long new_len,
26 unsigned long flags,
27 unsigned long new_addr);
28extern asmlinkage unsigned long c_sys_nis_syscall(struct pt_regs *regs);
29extern asmlinkage long sys_getdomainname(char __user *name, int len);
30extern asmlinkage long solaris_syscall(struct pt_regs *regs);
31extern asmlinkage long sunos_syscall(struct pt_regs *regs);
32extern asmlinkage long sys_utrap_install(utrap_entry_t type,
33 utrap_handler_t new_p,
34 utrap_handler_t new_d,
35 utrap_handler_t __user *old_p,
36 utrap_handler_t __user *old_d);
37extern asmlinkage long sparc_memory_ordering(unsigned long model,
38 struct pt_regs *regs);
39extern asmlinkage long sys_rt_sigaction(int sig,
40 const struct sigaction __user *act,
41 struct sigaction __user *oact,
42 void __user *restorer,
43 size_t sigsetsize);
44extern asmlinkage long sys_perfctr(int opcode, unsigned long arg0,
45 unsigned long arg1, unsigned long arg2);
46
47extern asmlinkage void sparc64_set_context(struct pt_regs *regs);
48extern asmlinkage void sparc64_get_context(struct pt_regs *regs);
49extern asmlinkage long sys_sigpause(unsigned int set);
50extern asmlinkage long sys_sigsuspend(old_sigset_t set);
51extern void do_rt_sigreturn(struct pt_regs *regs);
52
53#endif /* _SYSTBLS_H */
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index d204f1ab1d4c..e5d238970c7e 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -1,7 +1,6 @@
1/* $Id: time.c,v 1.42 2002/01/23 14:33:55 davem Exp $ 1/* time.c: UltraSparc timer and TOD clock support.
2 * time.c: UltraSparc timer and TOD clock support.
3 * 2 *
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) 3 * Copyright (C) 1997, 2008 David S. Miller (davem@davemloft.net)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) 4 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * 5 *
7 * Based largely on code which is: 6 * Based largely on code which is:
@@ -48,6 +47,8 @@
48#include <asm/uaccess.h> 47#include <asm/uaccess.h>
49#include <asm/irq_regs.h> 48#include <asm/irq_regs.h>
50 49
50#include "entry.h"
51
51DEFINE_SPINLOCK(mostek_lock); 52DEFINE_SPINLOCK(mostek_lock);
52DEFINE_SPINLOCK(rtc_lock); 53DEFINE_SPINLOCK(rtc_lock);
53void __iomem *mstk48t02_regs = NULL; 54void __iomem *mstk48t02_regs = NULL;
@@ -508,6 +509,37 @@ static int __init has_low_battery(void)
508 return (data1 == data2); /* Was the write blocked? */ 509 return (data1 == data2); /* Was the write blocked? */
509} 510}
510 511
512static void __init mostek_set_system_time(void __iomem *mregs)
513{
514 unsigned int year, mon, day, hour, min, sec;
515 u8 tmp;
516
517 spin_lock_irq(&mostek_lock);
518
519 /* Traditional Mostek chip. */
520 tmp = mostek_read(mregs + MOSTEK_CREG);
521 tmp |= MSTK_CREG_READ;
522 mostek_write(mregs + MOSTEK_CREG, tmp);
523
524 sec = MSTK_REG_SEC(mregs);
525 min = MSTK_REG_MIN(mregs);
526 hour = MSTK_REG_HOUR(mregs);
527 day = MSTK_REG_DOM(mregs);
528 mon = MSTK_REG_MONTH(mregs);
529 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
530
531 xtime.tv_sec = mktime(year, mon, day, hour, min, sec);
532 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
533 set_normalized_timespec(&wall_to_monotonic,
534 -xtime.tv_sec, -xtime.tv_nsec);
535
536 tmp = mostek_read(mregs + MOSTEK_CREG);
537 tmp &= ~MSTK_CREG_READ;
538 mostek_write(mregs + MOSTEK_CREG, tmp);
539
540 spin_unlock_irq(&mostek_lock);
541}
542
511/* Probe for the real time clock chip. */ 543/* Probe for the real time clock chip. */
512static void __init set_system_time(void) 544static void __init set_system_time(void)
513{ 545{
@@ -520,7 +552,6 @@ static void __init set_system_time(void)
520 unsigned long dregs = 0UL; 552 unsigned long dregs = 0UL;
521 void __iomem *bregs = 0UL; 553 void __iomem *bregs = 0UL;
522#endif 554#endif
523 u8 tmp;
524 555
525 if (!mregs && !dregs && !bregs) { 556 if (!mregs && !dregs && !bregs) {
526 prom_printf("Something wrong, clock regs not mapped yet.\n"); 557 prom_printf("Something wrong, clock regs not mapped yet.\n");
@@ -528,20 +559,11 @@ static void __init set_system_time(void)
528 } 559 }
529 560
530 if (mregs) { 561 if (mregs) {
531 spin_lock_irq(&mostek_lock); 562 mostek_set_system_time(mregs);
532 563 return;
533 /* Traditional Mostek chip. */ 564 }
534 tmp = mostek_read(mregs + MOSTEK_CREG);
535 tmp |= MSTK_CREG_READ;
536 mostek_write(mregs + MOSTEK_CREG, tmp);
537 565
538 sec = MSTK_REG_SEC(mregs); 566 if (bregs) {
539 min = MSTK_REG_MIN(mregs);
540 hour = MSTK_REG_HOUR(mregs);
541 day = MSTK_REG_DOM(mregs);
542 mon = MSTK_REG_MONTH(mregs);
543 year = MSTK_CVT_YEAR( MSTK_REG_YEAR(mregs) );
544 } else if (bregs) {
545 unsigned char val = readb(bregs + 0x0e); 567 unsigned char val = readb(bregs + 0x0e);
546 unsigned int century; 568 unsigned int century;
547 569
@@ -596,14 +618,6 @@ static void __init set_system_time(void)
596 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ); 618 xtime.tv_nsec = (INITIAL_JIFFIES % HZ) * (NSEC_PER_SEC / HZ);
597 set_normalized_timespec(&wall_to_monotonic, 619 set_normalized_timespec(&wall_to_monotonic,
598 -xtime.tv_sec, -xtime.tv_nsec); 620 -xtime.tv_sec, -xtime.tv_nsec);
599
600 if (mregs) {
601 tmp = mostek_read(mregs + MOSTEK_CREG);
602 tmp &= ~MSTK_CREG_READ;
603 mostek_write(mregs + MOSTEK_CREG, tmp);
604
605 spin_unlock_irq(&mostek_lock);
606 }
607} 621}
608 622
609/* davem suggests we keep this within the 4M locked kernel image */ 623/* davem suggests we keep this within the 4M locked kernel image */
@@ -1027,7 +1041,7 @@ void __init time_init(void)
1027 setup_clockevent_multiplier(clock); 1041 setup_clockevent_multiplier(clock);
1028 1042
1029 sparc64_clockevent.max_delta_ns = 1043 sparc64_clockevent.max_delta_ns =
1030 clockevent_delta2ns(0x7fffffffffffffff, &sparc64_clockevent); 1044 clockevent_delta2ns(0x7fffffffffffffffUL, &sparc64_clockevent);
1031 sparc64_clockevent.min_delta_ns = 1045 sparc64_clockevent.min_delta_ns =
1032 clockevent_delta2ns(0xF, &sparc64_clockevent); 1046 clockevent_delta2ns(0xF, &sparc64_clockevent);
1033 1047
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 007f5317c0de..96da847023f3 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -42,6 +42,7 @@
42#endif 42#endif
43#include <asm/prom.h> 43#include <asm/prom.h>
44 44
45#include "entry.h"
45 46
46/* When an irrecoverable trap occurs at tl > 0, the trap entry 47/* When an irrecoverable trap occurs at tl > 0, the trap entry
47 * code logs the trap state registers at every level in the trap 48 * code logs the trap state registers at every level in the trap
@@ -77,11 +78,6 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
77 } 78 }
78} 79}
79 80
80void do_call_debug(struct pt_regs *regs)
81{
82 notify_die(DIE_CALL, "debug call", regs, 0, 255, SIGINT);
83}
84
85void bad_trap(struct pt_regs *regs, long lvl) 81void bad_trap(struct pt_regs *regs, long lvl)
86{ 82{
87 char buffer[32]; 83 char buffer[32];
@@ -550,41 +546,6 @@ static unsigned long ecache_flush_physbase;
550static unsigned long ecache_flush_linesize; 546static unsigned long ecache_flush_linesize;
551static unsigned long ecache_flush_size; 547static unsigned long ecache_flush_size;
552 548
553/* WARNING: The error trap handlers in assembly know the precise
554 * layout of the following structure.
555 *
556 * C-level handlers below use this information to log the error
557 * and then determine how to recover (if possible).
558 */
559struct cheetah_err_info {
560/*0x00*/u64 afsr;
561/*0x08*/u64 afar;
562
563 /* D-cache state */
564/*0x10*/u64 dcache_data[4]; /* The actual data */
565/*0x30*/u64 dcache_index; /* D-cache index */
566/*0x38*/u64 dcache_tag; /* D-cache tag/valid */
567/*0x40*/u64 dcache_utag; /* D-cache microtag */
568/*0x48*/u64 dcache_stag; /* D-cache snooptag */
569
570 /* I-cache state */
571/*0x50*/u64 icache_data[8]; /* The actual insns + predecode */
572/*0x90*/u64 icache_index; /* I-cache index */
573/*0x98*/u64 icache_tag; /* I-cache phys tag */
574/*0xa0*/u64 icache_utag; /* I-cache microtag */
575/*0xa8*/u64 icache_stag; /* I-cache snooptag */
576/*0xb0*/u64 icache_upper; /* I-cache upper-tag */
577/*0xb8*/u64 icache_lower; /* I-cache lower-tag */
578
579 /* E-cache state */
580/*0xc0*/u64 ecache_data[4]; /* 32 bytes from staging registers */
581/*0xe0*/u64 ecache_index; /* E-cache index */
582/*0xe8*/u64 ecache_tag; /* E-cache tag/state */
583
584/*0xf0*/u64 __pad[32 - 30];
585};
586#define CHAFSR_INVALID ((u64)-1L)
587
588/* This table is ordered in priority of errors and matches the 549/* This table is ordered in priority of errors and matches the
589 * AFAR overwrite policy as well. 550 * AFAR overwrite policy as well.
590 */ 551 */
@@ -758,10 +719,6 @@ static struct afsr_error_table __jalapeno_error_table[] = {
758static struct afsr_error_table *cheetah_error_table; 719static struct afsr_error_table *cheetah_error_table;
759static unsigned long cheetah_afsr_errors; 720static unsigned long cheetah_afsr_errors;
760 721
761/* This is allocated at boot time based upon the largest hardware
762 * cpu ID in the system. We allocate two entries per cpu, one for
763 * TL==0 logging and one for TL >= 1 logging.
764 */
765struct cheetah_err_info *cheetah_error_log; 722struct cheetah_err_info *cheetah_error_log;
766 723
767static inline struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr) 724static inline struct cheetah_err_info *cheetah_get_error_log(unsigned long afsr)
@@ -2102,7 +2059,7 @@ void do_div0(struct pt_regs *regs)
2102 force_sig_info(SIGFPE, &info, current); 2059 force_sig_info(SIGFPE, &info, current);
2103} 2060}
2104 2061
2105void instruction_dump (unsigned int *pc) 2062static void instruction_dump(unsigned int *pc)
2106{ 2063{
2107 int i; 2064 int i;
2108 2065
@@ -2115,7 +2072,7 @@ void instruction_dump (unsigned int *pc)
2115 printk("\n"); 2072 printk("\n");
2116} 2073}
2117 2074
2118static void user_instruction_dump (unsigned int __user *pc) 2075static void user_instruction_dump(unsigned int __user *pc)
2119{ 2076{
2120 int i; 2077 int i;
2121 unsigned int buf[9]; 2078 unsigned int buf[9];
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 466fd6cffac9..f37078d96407 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -46,6 +46,7 @@
46#include <asm/prom.h> 46#include <asm/prom.h>
47#include <asm/sstate.h> 47#include <asm/sstate.h>
48#include <asm/mdesc.h> 48#include <asm/mdesc.h>
49#include <asm/cpudata.h>
49 50
50#define MAX_PHYS_ADDRESS (1UL << 42UL) 51#define MAX_PHYS_ADDRESS (1UL << 42UL)
51#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) 52#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
@@ -1273,10 +1274,6 @@ void __cpuinit sun4v_ktsb_register(void)
1273 1274
1274/* paging_init() sets up the page tables */ 1275/* paging_init() sets up the page tables */
1275 1276
1276extern void cheetah_ecache_flush_init(void);
1277extern void sun4v_patch_tlb_handlers(void);
1278
1279extern void cpu_probe(void);
1280extern void central_probe(void); 1277extern void central_probe(void);
1281 1278
1282static unsigned long last_valid_pfn; 1279static unsigned long last_valid_pfn;
diff --git a/arch/sparc64/mm/tlb.c b/arch/sparc64/mm/tlb.c
index 3f10fc921b00..ae24919cba7c 100644
--- a/arch/sparc64/mm/tlb.c
+++ b/arch/sparc64/mm/tlb.c
@@ -23,9 +23,7 @@ DEFINE_PER_CPU(struct mmu_gather, mmu_gathers) = { 0, };
23 23
24void flush_tlb_pending(void) 24void flush_tlb_pending(void)
25{ 25{
26 struct mmu_gather *mp = &__get_cpu_var(mmu_gathers); 26 struct mmu_gather *mp = &get_cpu_var(mmu_gathers);
27
28 preempt_disable();
29 27
30 if (mp->tlb_nr) { 28 if (mp->tlb_nr) {
31 flush_tsb_user(mp); 29 flush_tsb_user(mp);
@@ -42,7 +40,7 @@ void flush_tlb_pending(void)
42 mp->tlb_nr = 0; 40 mp->tlb_nr = 0;
43 } 41 }
44 42
45 preempt_enable(); 43 put_cpu_var(mmu_gathers);
46} 44}
47 45
48void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig) 46void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig)