aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 15:06:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-28 15:06:51 -0400
commit3c3762957818dc902222733a8184f23102e24472 (patch)
tree97a17d0923d87108715af32f83a526d24e65fb80 /arch
parente9f29c9a56ca06d0effa557823a737cbe7ec09f7 (diff)
parent63111a3a70fb4d80e3b54ed75f13795e98f7a467 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6: (32 commits) sh: intc: switch irq_desc iteration to new active IRQ iterator. sh: fix up cpu hotplug IRQ migration for irq_data changes. sh: oprofile: Make sure the backtrace op is available for timer-fallback. sh64: oprofile: Fix up kernel stack pointer size mismatch. sh: oprofile: Fix up and extend op_name_from_perf_id(). sh: lockless get_user_pages_fast() sh64: _PAGE_SPECIAL support. sound: sh: ctrl_in/outX to __raw_read/writeX conversion. sh: disable deprecated genirq support. sh: update show_interrupts() for irq_data chip lookup. sh: intc: irq_data conversion. sh64: irq_data conversion. sh64: update for IRQ flag handling naming changes. rtc: rtc-rs5c313: ctrl_in/outX to __raw_read/writeX conversion. sh: mach-se: irq_data conversion. input: hp680_ts_input: ctrl_in/outX to __raw_read/writeX conversion. input: jornada680_kbd: ctrl_in/outX to __raw_read/writeX conversion. sh: hd64461: irq_data conversion. sh: mach-x3proto: irq_data conversion. sh: mach-systemh: irq_data conversion. ...
Diffstat (limited to 'arch')
-rw-r--r--arch/sh/Kconfig14
-rw-r--r--arch/sh/boards/mach-cayman/irq.c16
-rw-r--r--arch/sh/boards/mach-dreamcast/irq.c17
-rw-r--r--arch/sh/boards/mach-landisk/irq.c15
-rw-r--r--arch/sh/boards/mach-microdev/irq.c30
-rw-r--r--arch/sh/boards/mach-se/7206/irq.c20
-rw-r--r--arch/sh/boards/mach-se/7343/irq.c15
-rw-r--r--arch/sh/boards/mach-se/7722/irq.c15
-rw-r--r--arch/sh/boards/mach-se/7724/irq.c13
-rw-r--r--arch/sh/boards/mach-systemh/irq.c57
-rw-r--r--arch/sh/boards/mach-x3proto/gpio.c7
-rw-r--r--arch/sh/cchips/hd6446x/hd64461.c19
-rw-r--r--arch/sh/include/asm/pgtable.h2
-rw-r--r--arch/sh/include/asm/pgtable_32.h2
-rw-r--r--arch/sh/include/asm/pgtable_64.h9
-rw-r--r--arch/sh/include/asm/processor.h1
-rw-r--r--arch/sh/kernel/cpu/init.c2
-rw-r--r--arch/sh/kernel/cpu/irq/imask.c14
-rw-r--r--arch/sh/kernel/cpu/irq/intc-sh5.c49
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c29
-rw-r--r--arch/sh/kernel/cpu/sh4/perf_event.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/perf_event.c2
-rw-r--r--arch/sh/kernel/irq.c37
-rw-r--r--arch/sh/kernel/irq_64.c16
-rw-r--r--arch/sh/kernel/setup.c4
-rw-r--r--arch/sh/mm/Makefile2
-rw-r--r--arch/sh/mm/gup.c273
-rw-r--r--arch/sh/oprofile/Makefile2
-rw-r--r--arch/sh/oprofile/backtrace.c2
-rw-r--r--arch/sh/oprofile/common.c35
30 files changed, 478 insertions, 243 deletions
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 0f40fc35d0a2..792cf902743a 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -25,8 +25,11 @@ config SUPERH
25 select HAVE_KERNEL_LZO 25 select HAVE_KERNEL_LZO
26 select HAVE_SYSCALL_TRACEPOINTS 26 select HAVE_SYSCALL_TRACEPOINTS
27 select HAVE_REGS_AND_STACK_ACCESS_API 27 select HAVE_REGS_AND_STACK_ACCESS_API
28 select HAVE_GENERIC_HARDIRQS
29 select HAVE_SPARSE_IRQ
28 select RTC_LIB 30 select RTC_LIB
29 select GENERIC_ATOMIC64 31 select GENERIC_ATOMIC64
32 select GENERIC_HARDIRQS_NO_DEPRECATED
30 help 33 help
31 The SuperH is a RISC processor targeted for use in embedded systems 34 The SuperH is a RISC processor targeted for use in embedded systems
32 and consumer electronics; it was also used in the Sega Dreamcast 35 and consumer electronics; it was also used in the Sega Dreamcast
@@ -49,6 +52,7 @@ config SUPERH32
49 select HAVE_MIXED_BREAKPOINTS_REGS 52 select HAVE_MIXED_BREAKPOINTS_REGS
50 select PERF_EVENTS 53 select PERF_EVENTS
51 select ARCH_HIBERNATION_POSSIBLE if MMU 54 select ARCH_HIBERNATION_POSSIBLE if MMU
55 select SPARSE_IRQ
52 56
53config SUPERH64 57config SUPERH64
54 def_bool ARCH = "sh64" 58 def_bool ARCH = "sh64"
@@ -78,19 +82,9 @@ config GENERIC_FIND_NEXT_BIT
78config GENERIC_HWEIGHT 82config GENERIC_HWEIGHT
79 def_bool y 83 def_bool y
80 84
81config GENERIC_HARDIRQS
82 def_bool y
83
84config GENERIC_HARDIRQS_NO__DO_IRQ
85 def_bool y
86
87config IRQ_PER_CPU 85config IRQ_PER_CPU
88 def_bool y 86 def_bool y
89 87
90config SPARSE_IRQ
91 def_bool y
92 depends on SUPERH32
93
94config GENERIC_GPIO 88config GENERIC_GPIO
95 def_bool n 89 def_bool n
96 90
diff --git a/arch/sh/boards/mach-cayman/irq.c b/arch/sh/boards/mach-cayman/irq.c
index 1394b078db36..d7ac5af9d102 100644
--- a/arch/sh/boards/mach-cayman/irq.c
+++ b/arch/sh/boards/mach-cayman/irq.c
@@ -55,8 +55,9 @@ static struct irqaction cayman_action_pci2 = {
55 .flags = IRQF_DISABLED, 55 .flags = IRQF_DISABLED,
56}; 56};
57 57
58static void enable_cayman_irq(unsigned int irq) 58static void enable_cayman_irq(struct irq_data *data)
59{ 59{
60 unsigned int irq = data->irq;
60 unsigned long flags; 61 unsigned long flags;
61 unsigned long mask; 62 unsigned long mask;
62 unsigned int reg; 63 unsigned int reg;
@@ -72,8 +73,9 @@ static void enable_cayman_irq(unsigned int irq)
72 local_irq_restore(flags); 73 local_irq_restore(flags);
73} 74}
74 75
75void disable_cayman_irq(unsigned int irq) 76static void disable_cayman_irq(struct irq_data *data)
76{ 77{
78 unsigned int irq = data->irq;
77 unsigned long flags; 79 unsigned long flags;
78 unsigned long mask; 80 unsigned long mask;
79 unsigned int reg; 81 unsigned int reg;
@@ -89,16 +91,10 @@ void disable_cayman_irq(unsigned int irq)
89 local_irq_restore(flags); 91 local_irq_restore(flags);
90} 92}
91 93
92static void ack_cayman_irq(unsigned int irq)
93{
94 disable_cayman_irq(irq);
95}
96
97struct irq_chip cayman_irq_type = { 94struct irq_chip cayman_irq_type = {
98 .name = "Cayman-IRQ", 95 .name = "Cayman-IRQ",
99 .unmask = enable_cayman_irq, 96 .irq_unmask = enable_cayman_irq,
100 .mask = disable_cayman_irq, 97 .irq_mask = disable_cayman_irq,
101 .mask_ack = ack_cayman_irq,
102}; 98};
103 99
104int cayman_irq_demux(int evt) 100int cayman_irq_demux(int evt)
diff --git a/arch/sh/boards/mach-dreamcast/irq.c b/arch/sh/boards/mach-dreamcast/irq.c
index d932667410ab..72e7ac9549da 100644
--- a/arch/sh/boards/mach-dreamcast/irq.c
+++ b/arch/sh/boards/mach-dreamcast/irq.c
@@ -60,8 +60,9 @@
60 */ 60 */
61 61
62/* Disable the hardware event by masking its bit in its EMR */ 62/* Disable the hardware event by masking its bit in its EMR */
63static inline void disable_systemasic_irq(unsigned int irq) 63static inline void disable_systemasic_irq(struct irq_data *data)
64{ 64{
65 unsigned int irq = data->irq;
65 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 66 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
66 __u32 mask; 67 __u32 mask;
67 68
@@ -71,8 +72,9 @@ static inline void disable_systemasic_irq(unsigned int irq)
71} 72}
72 73
73/* Enable the hardware event by setting its bit in its EMR */ 74/* Enable the hardware event by setting its bit in its EMR */
74static inline void enable_systemasic_irq(unsigned int irq) 75static inline void enable_systemasic_irq(struct irq_data *data)
75{ 76{
77 unsigned int irq = data->irq;
76 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 78 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
77 __u32 mask; 79 __u32 mask;
78 80
@@ -82,18 +84,19 @@ static inline void enable_systemasic_irq(unsigned int irq)
82} 84}
83 85
84/* Acknowledge a hardware event by writing its bit back to its ESR */ 86/* Acknowledge a hardware event by writing its bit back to its ESR */
85static void mask_ack_systemasic_irq(unsigned int irq) 87static void mask_ack_systemasic_irq(struct irq_data *data)
86{ 88{
89 unsigned int irq = data->irq;
87 __u32 esr = ESR_BASE + (LEVEL(irq) << 2); 90 __u32 esr = ESR_BASE + (LEVEL(irq) << 2);
88 disable_systemasic_irq(irq); 91 disable_systemasic_irq(data);
89 outl((1 << EVENT_BIT(irq)), esr); 92 outl((1 << EVENT_BIT(irq)), esr);
90} 93}
91 94
92struct irq_chip systemasic_int = { 95struct irq_chip systemasic_int = {
93 .name = "System ASIC", 96 .name = "System ASIC",
94 .mask = disable_systemasic_irq, 97 .irq_mask = disable_systemasic_irq,
95 .mask_ack = mask_ack_systemasic_irq, 98 .irq_mask_ack = mask_ack_systemasic_irq,
96 .unmask = enable_systemasic_irq, 99 .irq_unmask = enable_systemasic_irq,
97}; 100};
98 101
99/* 102/*
diff --git a/arch/sh/boards/mach-landisk/irq.c b/arch/sh/boards/mach-landisk/irq.c
index 96f38a4187d0..e79412a40490 100644
--- a/arch/sh/boards/mach-landisk/irq.c
+++ b/arch/sh/boards/mach-landisk/irq.c
@@ -18,25 +18,24 @@
18#include <linux/io.h> 18#include <linux/io.h>
19#include <mach-landisk/mach/iodata_landisk.h> 19#include <mach-landisk/mach/iodata_landisk.h>
20 20
21static void disable_landisk_irq(unsigned int irq) 21static void disable_landisk_irq(struct irq_data *data)
22{ 22{
23 unsigned char mask = 0xff ^ (0x01 << (irq - 5)); 23 unsigned char mask = 0xff ^ (0x01 << (data->irq - 5));
24 24
25 __raw_writeb(__raw_readb(PA_IMASK) & mask, PA_IMASK); 25 __raw_writeb(__raw_readb(PA_IMASK) & mask, PA_IMASK);
26} 26}
27 27
28static void enable_landisk_irq(unsigned int irq) 28static void enable_landisk_irq(struct irq_data *data)
29{ 29{
30 unsigned char value = (0x01 << (irq - 5)); 30 unsigned char value = (0x01 << (data->irq - 5));
31 31
32 __raw_writeb(__raw_readb(PA_IMASK) | value, PA_IMASK); 32 __raw_writeb(__raw_readb(PA_IMASK) | value, PA_IMASK);
33} 33}
34 34
35static struct irq_chip landisk_irq_chip __read_mostly = { 35static struct irq_chip landisk_irq_chip __read_mostly = {
36 .name = "LANDISK", 36 .name = "LANDISK",
37 .mask = disable_landisk_irq, 37 .irq_mask = disable_landisk_irq,
38 .unmask = enable_landisk_irq, 38 .irq_unmask = enable_landisk_irq,
39 .mask_ack = disable_landisk_irq,
40}; 39};
41 40
42/* 41/*
@@ -50,7 +49,7 @@ void __init init_landisk_IRQ(void)
50 disable_irq_nosync(i); 49 disable_irq_nosync(i);
51 set_irq_chip_and_handler_name(i, &landisk_irq_chip, 50 set_irq_chip_and_handler_name(i, &landisk_irq_chip,
52 handle_level_irq, "level"); 51 handle_level_irq, "level");
53 enable_landisk_irq(i); 52 enable_landisk_irq(irq_get_irq_data(i));
54 } 53 }
55 __raw_writeb(0x00, PA_PWRINT_CLR); 54 __raw_writeb(0x00, PA_PWRINT_CLR);
56} 55}
diff --git a/arch/sh/boards/mach-microdev/irq.c b/arch/sh/boards/mach-microdev/irq.c
index a26d16669aa2..c35001fd9032 100644
--- a/arch/sh/boards/mach-microdev/irq.c
+++ b/arch/sh/boards/mach-microdev/irq.c
@@ -65,19 +65,9 @@ static const struct {
65# error Inconsistancy in defining the IRQ# for primary IDE! 65# error Inconsistancy in defining the IRQ# for primary IDE!
66#endif 66#endif
67 67
68static void enable_microdev_irq(unsigned int irq); 68static void disable_microdev_irq(struct irq_data *data)
69static void disable_microdev_irq(unsigned int irq);
70static void mask_and_ack_microdev(unsigned int);
71
72static struct irq_chip microdev_irq_type = {
73 .name = "MicroDev-IRQ",
74 .unmask = enable_microdev_irq,
75 .mask = disable_microdev_irq,
76 .ack = mask_and_ack_microdev,
77};
78
79static void disable_microdev_irq(unsigned int irq)
80{ 69{
70 unsigned int irq = data->irq;
81 unsigned int fpgaIrq; 71 unsigned int fpgaIrq;
82 72
83 if (irq >= NUM_EXTERNAL_IRQS) 73 if (irq >= NUM_EXTERNAL_IRQS)
@@ -91,8 +81,9 @@ static void disable_microdev_irq(unsigned int irq)
91 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG); 81 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
92} 82}
93 83
94static void enable_microdev_irq(unsigned int irq) 84static void enable_microdev_irq(struct irq_data *data)
95{ 85{
86 unsigned int irq = data->irq;
96 unsigned long priorityReg, priorities, pri; 87 unsigned long priorityReg, priorities, pri;
97 unsigned int fpgaIrq; 88 unsigned int fpgaIrq;
98 89
@@ -116,17 +107,18 @@ static void enable_microdev_irq(unsigned int irq)
116 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG); 107 __raw_writel(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
117} 108}
118 109
110static struct irq_chip microdev_irq_type = {
111 .name = "MicroDev-IRQ",
112 .irq_unmask = enable_microdev_irq,
113 .irq_mask = disable_microdev_irq,
114};
115
119/* This function sets the desired irq handler to be a MicroDev type */ 116/* This function sets the desired irq handler to be a MicroDev type */
120static void __init make_microdev_irq(unsigned int irq) 117static void __init make_microdev_irq(unsigned int irq)
121{ 118{
122 disable_irq_nosync(irq); 119 disable_irq_nosync(irq);
123 set_irq_chip_and_handler(irq, &microdev_irq_type, handle_level_irq); 120 set_irq_chip_and_handler(irq, &microdev_irq_type, handle_level_irq);
124 disable_microdev_irq(irq); 121 disable_microdev_irq(irq_get_irq_data(irq));
125}
126
127static void mask_and_ack_microdev(unsigned int irq)
128{
129 disable_microdev_irq(irq);
130} 122}
131 123
132extern void __init init_microdev_irq(void) 124extern void __init init_microdev_irq(void)
diff --git a/arch/sh/boards/mach-se/7206/irq.c b/arch/sh/boards/mach-se/7206/irq.c
index 8d82175d83ab..883b21eacaa6 100644
--- a/arch/sh/boards/mach-se/7206/irq.c
+++ b/arch/sh/boards/mach-se/7206/irq.c
@@ -25,8 +25,9 @@
25#define INTC_IPR01 0xfffe0818 25#define INTC_IPR01 0xfffe0818
26#define INTC_ICR1 0xfffe0802 26#define INTC_ICR1 0xfffe0802
27 27
28static void disable_se7206_irq(unsigned int irq) 28static void disable_se7206_irq(struct irq_data *data)
29{ 29{
30 unsigned int irq = data->irq;
30 unsigned short val; 31 unsigned short val;
31 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq))); 32 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
32 unsigned short msk0,msk1; 33 unsigned short msk0,msk1;
@@ -55,8 +56,9 @@ static void disable_se7206_irq(unsigned int irq)
55 __raw_writew(msk1, INTMSK1); 56 __raw_writew(msk1, INTMSK1);
56} 57}
57 58
58static void enable_se7206_irq(unsigned int irq) 59static void enable_se7206_irq(struct irq_data *data)
59{ 60{
61 unsigned int irq = data->irq;
60 unsigned short val; 62 unsigned short val;
61 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq))); 63 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
62 unsigned short msk0,msk1; 64 unsigned short msk0,msk1;
@@ -86,13 +88,14 @@ static void enable_se7206_irq(unsigned int irq)
86 __raw_writew(msk1, INTMSK1); 88 __raw_writew(msk1, INTMSK1);
87} 89}
88 90
89static void eoi_se7206_irq(unsigned int irq) 91static void eoi_se7206_irq(struct irq_data *data)
90{ 92{
91 unsigned short sts0,sts1; 93 unsigned short sts0,sts1;
94 unsigned int irq = data->irq;
92 struct irq_desc *desc = irq_to_desc(irq); 95 struct irq_desc *desc = irq_to_desc(irq);
93 96
94 if (!(desc->status & (IRQ_DISABLED|IRQ_INPROGRESS))) 97 if (!(desc->status & (IRQ_DISABLED|IRQ_INPROGRESS)))
95 enable_se7206_irq(irq); 98 enable_se7206_irq(data);
96 /* FPGA isr clear */ 99 /* FPGA isr clear */
97 sts0 = __raw_readw(INTSTS0); 100 sts0 = __raw_readw(INTSTS0);
98 sts1 = __raw_readw(INTSTS1); 101 sts1 = __raw_readw(INTSTS1);
@@ -115,10 +118,9 @@ static void eoi_se7206_irq(unsigned int irq)
115 118
116static struct irq_chip se7206_irq_chip __read_mostly = { 119static struct irq_chip se7206_irq_chip __read_mostly = {
117 .name = "SE7206-FPGA", 120 .name = "SE7206-FPGA",
118 .mask = disable_se7206_irq, 121 .irq_mask = disable_se7206_irq,
119 .unmask = enable_se7206_irq, 122 .irq_unmask = enable_se7206_irq,
120 .mask_ack = disable_se7206_irq, 123 .irq_eoi = eoi_se7206_irq,
121 .eoi = eoi_se7206_irq,
122}; 124};
123 125
124static void make_se7206_irq(unsigned int irq) 126static void make_se7206_irq(unsigned int irq)
@@ -126,7 +128,7 @@ static void make_se7206_irq(unsigned int irq)
126 disable_irq_nosync(irq); 128 disable_irq_nosync(irq);
127 set_irq_chip_and_handler_name(irq, &se7206_irq_chip, 129 set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
128 handle_level_irq, "level"); 130 handle_level_irq, "level");
129 disable_se7206_irq(irq); 131 disable_se7206_irq(irq_get_irq_data(irq));
130} 132}
131 133
132/* 134/*
diff --git a/arch/sh/boards/mach-se/7343/irq.c b/arch/sh/boards/mach-se/7343/irq.c
index d4305c26e9f7..76255a19417f 100644
--- a/arch/sh/boards/mach-se/7343/irq.c
+++ b/arch/sh/boards/mach-se/7343/irq.c
@@ -18,23 +18,22 @@
18 18
19unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, }; 19unsigned int se7343_fpga_irq[SE7343_FPGA_IRQ_NR] = { 0, };
20 20
21static void disable_se7343_irq(unsigned int irq) 21static void disable_se7343_irq(struct irq_data *data)
22{ 22{
23 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 23 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24 __raw_writew(__raw_readw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK); 24 __raw_writew(__raw_readw(PA_CPLD_IMSK) | 1 << bit, PA_CPLD_IMSK);
25} 25}
26 26
27static void enable_se7343_irq(unsigned int irq) 27static void enable_se7343_irq(struct irq_data *data)
28{ 28{
29 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
30 __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK); 30 __raw_writew(__raw_readw(PA_CPLD_IMSK) & ~(1 << bit), PA_CPLD_IMSK);
31} 31}
32 32
33static struct irq_chip se7343_irq_chip __read_mostly = { 33static struct irq_chip se7343_irq_chip __read_mostly = {
34 .name = "SE7343-FPGA", 34 .name = "SE7343-FPGA",
35 .mask = disable_se7343_irq, 35 .irq_mask = disable_se7343_irq,
36 .unmask = enable_se7343_irq, 36 .irq_unmask = enable_se7343_irq,
37 .mask_ack = disable_se7343_irq,
38}; 37};
39 38
40static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc) 39static void se7343_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-se/7722/irq.c b/arch/sh/boards/mach-se/7722/irq.c
index 61605db04ee6..c013f95628ed 100644
--- a/arch/sh/boards/mach-se/7722/irq.c
+++ b/arch/sh/boards/mach-se/7722/irq.c
@@ -18,23 +18,22 @@
18 18
19unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, }; 19unsigned int se7722_fpga_irq[SE7722_FPGA_IRQ_NR] = { 0, };
20 20
21static void disable_se7722_irq(unsigned int irq) 21static void disable_se7722_irq(struct irq_data *data)
22{ 22{
23 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 23 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
24 __raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK); 24 __raw_writew(__raw_readw(IRQ01_MASK) | 1 << bit, IRQ01_MASK);
25} 25}
26 26
27static void enable_se7722_irq(unsigned int irq) 27static void enable_se7722_irq(struct irq_data *data)
28{ 28{
29 unsigned int bit = (unsigned int)get_irq_chip_data(irq); 29 unsigned int bit = (unsigned int)irq_data_get_irq_chip_data(data);
30 __raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK); 30 __raw_writew(__raw_readw(IRQ01_MASK) & ~(1 << bit), IRQ01_MASK);
31} 31}
32 32
33static struct irq_chip se7722_irq_chip __read_mostly = { 33static struct irq_chip se7722_irq_chip __read_mostly = {
34 .name = "SE7722-FPGA", 34 .name = "SE7722-FPGA",
35 .mask = disable_se7722_irq, 35 .irq_mask = disable_se7722_irq,
36 .unmask = enable_se7722_irq, 36 .irq_unmask = enable_se7722_irq,
37 .mask_ack = disable_se7722_irq,
38}; 37};
39 38
40static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc) 39static void se7722_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-se/7724/irq.c b/arch/sh/boards/mach-se/7724/irq.c
index 0942be2daef6..5bd87c22b65b 100644
--- a/arch/sh/boards/mach-se/7724/irq.c
+++ b/arch/sh/boards/mach-se/7724/irq.c
@@ -68,25 +68,26 @@ static struct fpga_irq get_fpga_irq(unsigned int irq)
68 return set; 68 return set;
69} 69}
70 70
71static void disable_se7724_irq(unsigned int irq) 71static void disable_se7724_irq(struct irq_data *data)
72{ 72{
73 unsigned int irq = data->irq;
73 struct fpga_irq set = get_fpga_irq(fpga2irq(irq)); 74 struct fpga_irq set = get_fpga_irq(fpga2irq(irq));
74 unsigned int bit = irq - set.base; 75 unsigned int bit = irq - set.base;
75 __raw_writew(__raw_readw(set.mraddr) | 0x0001 << bit, set.mraddr); 76 __raw_writew(__raw_readw(set.mraddr) | 0x0001 << bit, set.mraddr);
76} 77}
77 78
78static void enable_se7724_irq(unsigned int irq) 79static void enable_se7724_irq(struct irq_data *data)
79{ 80{
81 unsigned int irq = data->irq;
80 struct fpga_irq set = get_fpga_irq(fpga2irq(irq)); 82 struct fpga_irq set = get_fpga_irq(fpga2irq(irq));
81 unsigned int bit = irq - set.base; 83 unsigned int bit = irq - set.base;
82 __raw_writew(__raw_readw(set.mraddr) & ~(0x0001 << bit), set.mraddr); 84 __raw_writew(__raw_readw(set.mraddr) & ~(0x0001 << bit), set.mraddr);
83} 85}
84 86
85static struct irq_chip se7724_irq_chip __read_mostly = { 87static struct irq_chip se7724_irq_chip __read_mostly = {
86 .name = "SE7724-FPGA", 88 .name = "SE7724-FPGA",
87 .mask = disable_se7724_irq, 89 .irq_mask = disable_se7724_irq,
88 .unmask = enable_se7724_irq, 90 .irq_unmask = enable_se7724_irq,
89 .mask_ack = disable_se7724_irq,
90}; 91};
91 92
92static void se7724_irq_demux(unsigned int irq, struct irq_desc *desc) 93static void se7724_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/boards/mach-systemh/irq.c b/arch/sh/boards/mach-systemh/irq.c
index 523aea5dc94e..e5ee13adeff4 100644
--- a/arch/sh/boards/mach-systemh/irq.c
+++ b/arch/sh/boards/mach-systemh/irq.c
@@ -23,54 +23,39 @@
23static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004; 23static unsigned long *systemh_irq_mask_register = (unsigned long *)0xB3F10004;
24static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000; 24static unsigned long *systemh_irq_request_register = (unsigned long *)0xB3F10000;
25 25
26/* forward declaration */ 26static void disable_systemh_irq(struct irq_data *data)
27static void enable_systemh_irq(unsigned int irq);
28static void disable_systemh_irq(unsigned int irq);
29static void mask_and_ack_systemh(unsigned int);
30
31static struct irq_chip systemh_irq_type = {
32 .name = " SystemH Register",
33 .unmask = enable_systemh_irq,
34 .mask = disable_systemh_irq,
35 .ack = mask_and_ack_systemh,
36};
37
38static void disable_systemh_irq(unsigned int irq)
39{ 27{
40 if (systemh_irq_mask_register) { 28 unsigned long val, mask = 0x01 << 1;
41 unsigned long val, mask = 0x01 << 1;
42 29
43 /* Clear the "irq"th bit in the mask and set it in the request */ 30 /* Clear the "irq"th bit in the mask and set it in the request */
44 val = __raw_readl((unsigned long)systemh_irq_mask_register); 31 val = __raw_readl((unsigned long)systemh_irq_mask_register);
45 val &= ~mask; 32 val &= ~mask;
46 __raw_writel(val, (unsigned long)systemh_irq_mask_register); 33 __raw_writel(val, (unsigned long)systemh_irq_mask_register);
47 34
48 val = __raw_readl((unsigned long)systemh_irq_request_register); 35 val = __raw_readl((unsigned long)systemh_irq_request_register);
49 val |= mask; 36 val |= mask;
50 __raw_writel(val, (unsigned long)systemh_irq_request_register); 37 __raw_writel(val, (unsigned long)systemh_irq_request_register);
51 }
52} 38}
53 39
54static void enable_systemh_irq(unsigned int irq) 40static void enable_systemh_irq(struct irq_data *data)
55{ 41{
56 if (systemh_irq_mask_register) { 42 unsigned long val, mask = 0x01 << 1;
57 unsigned long val, mask = 0x01 << 1;
58 43
59 /* Set "irq"th bit in the mask register */ 44 /* Set "irq"th bit in the mask register */
60 val = __raw_readl((unsigned long)systemh_irq_mask_register); 45 val = __raw_readl((unsigned long)systemh_irq_mask_register);
61 val |= mask; 46 val |= mask;
62 __raw_writel(val, (unsigned long)systemh_irq_mask_register); 47 __raw_writel(val, (unsigned long)systemh_irq_mask_register);
63 }
64} 48}
65 49
66static void mask_and_ack_systemh(unsigned int irq) 50static struct irq_chip systemh_irq_type = {
67{ 51 .name = "SystemH Register",
68 disable_systemh_irq(irq); 52 .irq_unmask = enable_systemh_irq,
69} 53 .irq_mask = disable_systemh_irq,
54};
70 55
71void make_systemh_irq(unsigned int irq) 56void make_systemh_irq(unsigned int irq)
72{ 57{
73 disable_irq_nosync(irq); 58 disable_irq_nosync(irq);
74 set_irq_chip_and_handler(irq, &systemh_irq_type, handle_level_irq); 59 set_irq_chip_and_handler(irq, &systemh_irq_type, handle_level_irq);
75 disable_systemh_irq(irq); 60 disable_systemh_irq(irq_get_irq_data(irq));
76} 61}
diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c
index 594adf76e46a..239e74066253 100644
--- a/arch/sh/boards/mach-x3proto/gpio.c
+++ b/arch/sh/boards/mach-x3proto/gpio.c
@@ -54,18 +54,19 @@ static int x3proto_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
54 54
55static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) 55static void x3proto_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
56{ 56{
57 struct irq_chip *chip = get_irq_desc_chip(desc); 57 struct irq_data *data = irq_get_irq_data(irq);
58 struct irq_chip *chip = irq_data_get_irq_chip(data);
58 unsigned long mask; 59 unsigned long mask;
59 int pin; 60 int pin;
60 61
61 chip->mask_ack(irq); 62 chip->irq_mask_ack(data);
62 63
63 mask = __raw_readw(KEYDETR); 64 mask = __raw_readw(KEYDETR);
64 65
65 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS) 66 for_each_set_bit(pin, &mask, NR_BASEBOARD_GPIOS)
66 generic_handle_irq(x3proto_gpio_to_irq(NULL, pin)); 67 generic_handle_irq(x3proto_gpio_to_irq(NULL, pin));
67 68
68 chip->unmask(irq); 69 chip->irq_unmask(data);
69} 70}
70 71
71struct gpio_chip x3proto_gpio_chip = { 72struct gpio_chip x3proto_gpio_chip = {
diff --git a/arch/sh/cchips/hd6446x/hd64461.c b/arch/sh/cchips/hd6446x/hd64461.c
index bcb31ae84a51..177a10b25cad 100644
--- a/arch/sh/cchips/hd6446x/hd64461.c
+++ b/arch/sh/cchips/hd6446x/hd64461.c
@@ -17,8 +17,9 @@
17/* This belongs in cpu specific */ 17/* This belongs in cpu specific */
18#define INTC_ICR1 0xA4140010UL 18#define INTC_ICR1 0xA4140010UL
19 19
20static void hd64461_mask_irq(unsigned int irq) 20static void hd64461_mask_irq(struct irq_data *data)
21{ 21{
22 unsigned int irq = data->irq;
22 unsigned short nimr; 23 unsigned short nimr;
23 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 24 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
24 25
@@ -27,8 +28,9 @@ static void hd64461_mask_irq(unsigned int irq)
27 __raw_writew(nimr, HD64461_NIMR); 28 __raw_writew(nimr, HD64461_NIMR);
28} 29}
29 30
30static void hd64461_unmask_irq(unsigned int irq) 31static void hd64461_unmask_irq(struct irq_data *data)
31{ 32{
33 unsigned int irq = data->irq;
32 unsigned short nimr; 34 unsigned short nimr;
33 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 35 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
34 36
@@ -37,20 +39,21 @@ static void hd64461_unmask_irq(unsigned int irq)
37 __raw_writew(nimr, HD64461_NIMR); 39 __raw_writew(nimr, HD64461_NIMR);
38} 40}
39 41
40static void hd64461_mask_and_ack_irq(unsigned int irq) 42static void hd64461_mask_and_ack_irq(struct irq_data *data)
41{ 43{
42 hd64461_mask_irq(irq); 44 hd64461_mask_irq(data);
45
43#ifdef CONFIG_HD64461_ENABLER 46#ifdef CONFIG_HD64461_ENABLER
44 if (irq == HD64461_IRQBASE + 13) 47 if (data->irq == HD64461_IRQBASE + 13)
45 __raw_writeb(0x00, HD64461_PCC1CSCR); 48 __raw_writeb(0x00, HD64461_PCC1CSCR);
46#endif 49#endif
47} 50}
48 51
49static struct irq_chip hd64461_irq_chip = { 52static struct irq_chip hd64461_irq_chip = {
50 .name = "HD64461-IRQ", 53 .name = "HD64461-IRQ",
51 .mask = hd64461_mask_irq, 54 .irq_mask = hd64461_mask_irq,
52 .mask_ack = hd64461_mask_and_ack_irq, 55 .irq_mask_ack = hd64461_mask_and_ack_irq,
53 .unmask = hd64461_unmask_irq, 56 .irq_unmask = hd64461_unmask_irq,
54}; 57};
55 58
56static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc) 59static void hd64461_irq_demux(unsigned int irq, struct irq_desc *desc)
diff --git a/arch/sh/include/asm/pgtable.h b/arch/sh/include/asm/pgtable.h
index 02f77450cd8f..a15f1058bbf4 100644
--- a/arch/sh/include/asm/pgtable.h
+++ b/arch/sh/include/asm/pgtable.h
@@ -169,6 +169,8 @@ extern void page_table_range_init(unsigned long start, unsigned long end,
169#define HAVE_ARCH_UNMAPPED_AREA 169#define HAVE_ARCH_UNMAPPED_AREA
170#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN 170#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
171 171
172#define __HAVE_ARCH_PTE_SPECIAL
173
172#include <asm-generic/pgtable.h> 174#include <asm-generic/pgtable.h>
173 175
174#endif /* __ASM_SH_PGTABLE_H */ 176#endif /* __ASM_SH_PGTABLE_H */
diff --git a/arch/sh/include/asm/pgtable_32.h b/arch/sh/include/asm/pgtable_32.h
index 69fdfbf14ea5..43528ec656ba 100644
--- a/arch/sh/include/asm/pgtable_32.h
+++ b/arch/sh/include/asm/pgtable_32.h
@@ -378,8 +378,6 @@ PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
378PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED); 378PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
379PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL); 379PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL);
380 380
381#define __HAVE_ARCH_PTE_SPECIAL
382
383/* 381/*
384 * Macro and implementation to make a page protection as uncachable. 382 * Macro and implementation to make a page protection as uncachable.
385 */ 383 */
diff --git a/arch/sh/include/asm/pgtable_64.h b/arch/sh/include/asm/pgtable_64.h
index 10a48111226d..42cb9dd52161 100644
--- a/arch/sh/include/asm/pgtable_64.h
+++ b/arch/sh/include/asm/pgtable_64.h
@@ -130,6 +130,7 @@ static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
130 * anything above the PPN field. 130 * anything above the PPN field.
131 */ 131 */
132#define _PAGE_WIRED _PAGE_EXT(0x001) /* software: wire the tlb entry */ 132#define _PAGE_WIRED _PAGE_EXT(0x001) /* software: wire the tlb entry */
133#define _PAGE_SPECIAL _PAGE_EXT(0x002)
133 134
134#define _PAGE_CLEAR_FLAGS (_PAGE_PRESENT | _PAGE_FILE | _PAGE_SHARED | \ 135#define _PAGE_CLEAR_FLAGS (_PAGE_PRESENT | _PAGE_FILE | _PAGE_SHARED | \
135 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_WIRED) 136 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_WIRED)
@@ -173,7 +174,8 @@ static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
173/* Default flags for a User page */ 174/* Default flags for a User page */
174#define _PAGE_TABLE (_KERNPG_TABLE | _PAGE_USER) 175#define _PAGE_TABLE (_KERNPG_TABLE | _PAGE_USER)
175 176
176#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 177#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \
178 _PAGE_SPECIAL)
177 179
178/* 180/*
179 * We have full permissions (Read/Write/Execute/Shared). 181 * We have full permissions (Read/Write/Execute/Shared).
@@ -263,7 +265,7 @@ static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
263static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 265static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
264static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 266static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
265static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; } 267static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_WRITE; }
266static inline int pte_special(pte_t pte){ return 0; } 268static inline int pte_special(pte_t pte){ return pte_val(pte) & _PAGE_SPECIAL; }
267 269
268static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; } 270static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_WRITE)); return pte; }
269static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 271static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
@@ -272,8 +274,7 @@ static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) |
272static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 274static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
273static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 275static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
274static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; } 276static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
275static inline pte_t pte_mkspecial(pte_t pte) { return pte; } 277static inline pte_t pte_mkspecial(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SPECIAL)); return pte; }
276
277 278
278/* 279/*
279 * Conversion functions: convert a page and protection to a page entry. 280 * Conversion functions: convert a page and protection to a page entry.
diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h
index 0a58cb25a658..c9e7cbc4768a 100644
--- a/arch/sh/include/asm/processor.h
+++ b/arch/sh/include/asm/processor.h
@@ -89,6 +89,7 @@ struct sh_cpuinfo {
89 struct task_struct *idle; 89 struct task_struct *idle;
90#endif 90#endif
91 91
92 unsigned int phys_bits;
92 unsigned long flags; 93 unsigned long flags;
93} __attribute__ ((aligned(L1_CACHE_BYTES))); 94} __attribute__ ((aligned(L1_CACHE_BYTES)));
94 95
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index 97661061ff20..fac742e514ee 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -340,6 +340,8 @@ asmlinkage void __cpuinit cpu_init(void)
340 */ 340 */
341 current_cpu_data.asid_cache = NO_CONTEXT; 341 current_cpu_data.asid_cache = NO_CONTEXT;
342 342
343 current_cpu_data.phys_bits = __in_29bit_mode() ? 29 : 32;
344
343 speculative_execution_init(); 345 speculative_execution_init();
344 expmask_init(); 346 expmask_init();
345 347
diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c
index a351ed84eec5..32c825c9488e 100644
--- a/arch/sh/kernel/cpu/irq/imask.c
+++ b/arch/sh/kernel/cpu/irq/imask.c
@@ -51,16 +51,20 @@ static inline void set_interrupt_registers(int ip)
51 : "t"); 51 : "t");
52} 52}
53 53
54static void mask_imask_irq(unsigned int irq) 54static void mask_imask_irq(struct irq_data *data)
55{ 55{
56 unsigned int irq = data->irq;
57
56 clear_bit(irq, imask_mask); 58 clear_bit(irq, imask_mask);
57 if (interrupt_priority < IMASK_PRIORITY - irq) 59 if (interrupt_priority < IMASK_PRIORITY - irq)
58 interrupt_priority = IMASK_PRIORITY - irq; 60 interrupt_priority = IMASK_PRIORITY - irq;
59 set_interrupt_registers(interrupt_priority); 61 set_interrupt_registers(interrupt_priority);
60} 62}
61 63
62static void unmask_imask_irq(unsigned int irq) 64static void unmask_imask_irq(struct irq_data *data)
63{ 65{
66 unsigned int irq = data->irq;
67
64 set_bit(irq, imask_mask); 68 set_bit(irq, imask_mask);
65 interrupt_priority = IMASK_PRIORITY - 69 interrupt_priority = IMASK_PRIORITY -
66 find_first_zero_bit(imask_mask, IMASK_PRIORITY); 70 find_first_zero_bit(imask_mask, IMASK_PRIORITY);
@@ -69,9 +73,9 @@ static void unmask_imask_irq(unsigned int irq)
69 73
70static struct irq_chip imask_irq_chip = { 74static struct irq_chip imask_irq_chip = {
71 .name = "SR.IMASK", 75 .name = "SR.IMASK",
72 .mask = mask_imask_irq, 76 .irq_mask = mask_imask_irq,
73 .unmask = unmask_imask_irq, 77 .irq_unmask = unmask_imask_irq,
74 .mask_ack = mask_imask_irq, 78 .irq_mask_ack = mask_imask_irq,
75}; 79};
76 80
77void make_imask_irq(unsigned int irq) 81void make_imask_irq(unsigned int irq)
diff --git a/arch/sh/kernel/cpu/irq/intc-sh5.c b/arch/sh/kernel/cpu/irq/intc-sh5.c
index 96a239583948..5af48f8357e5 100644
--- a/arch/sh/kernel/cpu/irq/intc-sh5.c
+++ b/arch/sh/kernel/cpu/irq/intc-sh5.c
@@ -76,39 +76,11 @@ int intc_evt_to_irq[(0xE20/0x20)+1] = {
76}; 76};
77 77
78static unsigned long intc_virt; 78static unsigned long intc_virt;
79
80static unsigned int startup_intc_irq(unsigned int irq);
81static void shutdown_intc_irq(unsigned int irq);
82static void enable_intc_irq(unsigned int irq);
83static void disable_intc_irq(unsigned int irq);
84static void mask_and_ack_intc(unsigned int);
85static void end_intc_irq(unsigned int irq);
86
87static struct irq_chip intc_irq_type = {
88 .name = "INTC",
89 .startup = startup_intc_irq,
90 .shutdown = shutdown_intc_irq,
91 .enable = enable_intc_irq,
92 .disable = disable_intc_irq,
93 .ack = mask_and_ack_intc,
94 .end = end_intc_irq
95};
96
97static int irlm; /* IRL mode */ 79static int irlm; /* IRL mode */
98 80
99static unsigned int startup_intc_irq(unsigned int irq) 81static void enable_intc_irq(struct irq_data *data)
100{
101 enable_intc_irq(irq);
102 return 0; /* never anything pending */
103}
104
105static void shutdown_intc_irq(unsigned int irq)
106{
107 disable_intc_irq(irq);
108}
109
110static void enable_intc_irq(unsigned int irq)
111{ 82{
83 unsigned int irq = data->irq;
112 unsigned long reg; 84 unsigned long reg;
113 unsigned long bitmask; 85 unsigned long bitmask;
114 86
@@ -126,8 +98,9 @@ static void enable_intc_irq(unsigned int irq)
126 __raw_writel(bitmask, reg); 98 __raw_writel(bitmask, reg);
127} 99}
128 100
129static void disable_intc_irq(unsigned int irq) 101static void disable_intc_irq(struct irq_data *data)
130{ 102{
103 unsigned int irq = data->irq;
131 unsigned long reg; 104 unsigned long reg;
132 unsigned long bitmask; 105 unsigned long bitmask;
133 106
@@ -142,15 +115,11 @@ static void disable_intc_irq(unsigned int irq)
142 __raw_writel(bitmask, reg); 115 __raw_writel(bitmask, reg);
143} 116}
144 117
145static void mask_and_ack_intc(unsigned int irq) 118static struct irq_chip intc_irq_type = {
146{ 119 .name = "INTC",
147 disable_intc_irq(irq); 120 .irq_enable = enable_intc_irq,
148} 121 .irq_disable = disable_intc_irq,
149 122};
150static void end_intc_irq(unsigned int irq)
151{
152 enable_intc_irq(irq);
153}
154 123
155void __init plat_irq_setup(void) 124void __init plat_irq_setup(void)
156{ 125{
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index 9282d965a1b6..7516c35ee514 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -24,25 +24,25 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/topology.h> 25#include <linux/topology.h>
26 26
27static inline struct ipr_desc *get_ipr_desc(unsigned int irq) 27static inline struct ipr_desc *get_ipr_desc(struct irq_data *data)
28{ 28{
29 struct irq_chip *chip = get_irq_chip(irq); 29 struct irq_chip *chip = irq_data_get_irq_chip(data);
30 return container_of(chip, struct ipr_desc, chip); 30 return container_of(chip, struct ipr_desc, chip);
31} 31}
32 32
33static void disable_ipr_irq(unsigned int irq) 33static void disable_ipr_irq(struct irq_data *data)
34{ 34{
35 struct ipr_data *p = get_irq_chip_data(irq); 35 struct ipr_data *p = irq_data_get_irq_chip_data(data);
36 unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx]; 36 unsigned long addr = get_ipr_desc(data)->ipr_offsets[p->ipr_idx];
37 /* Set the priority in IPR to 0 */ 37 /* Set the priority in IPR to 0 */
38 __raw_writew(__raw_readw(addr) & (0xffff ^ (0xf << p->shift)), addr); 38 __raw_writew(__raw_readw(addr) & (0xffff ^ (0xf << p->shift)), addr);
39 (void)__raw_readw(addr); /* Read back to flush write posting */ 39 (void)__raw_readw(addr); /* Read back to flush write posting */
40} 40}
41 41
42static void enable_ipr_irq(unsigned int irq) 42static void enable_ipr_irq(struct irq_data *data)
43{ 43{
44 struct ipr_data *p = get_irq_chip_data(irq); 44 struct ipr_data *p = irq_data_get_irq_chip_data(data);
45 unsigned long addr = get_ipr_desc(irq)->ipr_offsets[p->ipr_idx]; 45 unsigned long addr = get_ipr_desc(data)->ipr_offsets[p->ipr_idx];
46 /* Set priority in IPR back to original value */ 46 /* Set priority in IPR back to original value */
47 __raw_writew(__raw_readw(addr) | (p->priority << p->shift), addr); 47 __raw_writew(__raw_readw(addr) | (p->priority << p->shift), addr);
48} 48}
@@ -56,19 +56,18 @@ void register_ipr_controller(struct ipr_desc *desc)
56{ 56{
57 int i; 57 int i;
58 58
59 desc->chip.mask = disable_ipr_irq; 59 desc->chip.irq_mask = disable_ipr_irq;
60 desc->chip.unmask = enable_ipr_irq; 60 desc->chip.irq_unmask = enable_ipr_irq;
61 desc->chip.mask_ack = disable_ipr_irq;
62 61
63 for (i = 0; i < desc->nr_irqs; i++) { 62 for (i = 0; i < desc->nr_irqs; i++) {
64 struct ipr_data *p = desc->ipr_data + i; 63 struct ipr_data *p = desc->ipr_data + i;
65 struct irq_desc *irq_desc; 64 int res;
66 65
67 BUG_ON(p->ipr_idx >= desc->nr_offsets); 66 BUG_ON(p->ipr_idx >= desc->nr_offsets);
68 BUG_ON(!desc->ipr_offsets[p->ipr_idx]); 67 BUG_ON(!desc->ipr_offsets[p->ipr_idx]);
69 68
70 irq_desc = irq_to_desc_alloc_node(p->irq, numa_node_id()); 69 res = irq_alloc_desc_at(p->irq, numa_node_id());
71 if (unlikely(!irq_desc)) { 70 if (unlikely(res != p->irq && res != -EEXIST)) {
72 printk(KERN_INFO "can not get irq_desc for %d\n", 71 printk(KERN_INFO "can not get irq_desc for %d\n",
73 p->irq); 72 p->irq);
74 continue; 73 continue;
@@ -78,7 +77,7 @@ void register_ipr_controller(struct ipr_desc *desc)
78 set_irq_chip_and_handler_name(p->irq, &desc->chip, 77 set_irq_chip_and_handler_name(p->irq, &desc->chip,
79 handle_level_irq, "level"); 78 handle_level_irq, "level");
80 set_irq_chip_data(p->irq, p); 79 set_irq_chip_data(p->irq, p);
81 disable_ipr_irq(p->irq); 80 disable_ipr_irq(irq_get_irq_data(p->irq));
82 } 81 }
83} 82}
84EXPORT_SYMBOL(register_ipr_controller); 83EXPORT_SYMBOL(register_ipr_controller);
diff --git a/arch/sh/kernel/cpu/sh4/perf_event.c b/arch/sh/kernel/cpu/sh4/perf_event.c
index 7f9ecc9c2d02..dbf3b4bb71fe 100644
--- a/arch/sh/kernel/cpu/sh4/perf_event.c
+++ b/arch/sh/kernel/cpu/sh4/perf_event.c
@@ -225,7 +225,7 @@ static void sh7750_pmu_enable_all(void)
225} 225}
226 226
227static struct sh_pmu sh7750_pmu = { 227static struct sh_pmu sh7750_pmu = {
228 .name = "SH7750", 228 .name = "sh7750",
229 .num_events = 2, 229 .num_events = 2,
230 .event_map = sh7750_event_map, 230 .event_map = sh7750_event_map,
231 .max_events = ARRAY_SIZE(sh7750_general_events), 231 .max_events = ARRAY_SIZE(sh7750_general_events),
diff --git a/arch/sh/kernel/cpu/sh4a/perf_event.c b/arch/sh/kernel/cpu/sh4a/perf_event.c
index b8b873d8d6b5..580276525731 100644
--- a/arch/sh/kernel/cpu/sh4a/perf_event.c
+++ b/arch/sh/kernel/cpu/sh4a/perf_event.c
@@ -259,7 +259,7 @@ static void sh4a_pmu_enable_all(void)
259} 259}
260 260
261static struct sh_pmu sh4a_pmu = { 261static struct sh_pmu sh4a_pmu = {
262 .name = "SH-4A", 262 .name = "sh4a",
263 .num_events = 2, 263 .num_events = 2,
264 .event_map = sh4a_event_map, 264 .event_map = sh4a_event_map,
265 .max_events = ARRAY_SIZE(sh4a_general_events), 265 .max_events = ARRAY_SIZE(sh4a_general_events),
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 9dc447db8a44..68ecbe6c881a 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -56,6 +56,8 @@ int show_interrupts(struct seq_file *p, void *v)
56 int i = *(loff_t *)v, j, prec; 56 int i = *(loff_t *)v, j, prec;
57 struct irqaction *action; 57 struct irqaction *action;
58 struct irq_desc *desc; 58 struct irq_desc *desc;
59 struct irq_data *data;
60 struct irq_chip *chip;
59 61
60 if (i > nr_irqs) 62 if (i > nr_irqs)
61 return 0; 63 return 0;
@@ -77,6 +79,9 @@ int show_interrupts(struct seq_file *p, void *v)
77 if (!desc) 79 if (!desc)
78 return 0; 80 return 0;
79 81
82 data = irq_get_irq_data(i);
83 chip = irq_data_get_irq_chip(data);
84
80 raw_spin_lock_irqsave(&desc->lock, flags); 85 raw_spin_lock_irqsave(&desc->lock, flags);
81 for_each_online_cpu(j) 86 for_each_online_cpu(j)
82 any_count |= kstat_irqs_cpu(i, j); 87 any_count |= kstat_irqs_cpu(i, j);
@@ -87,7 +92,7 @@ int show_interrupts(struct seq_file *p, void *v)
87 seq_printf(p, "%*d: ", prec, i); 92 seq_printf(p, "%*d: ", prec, i);
88 for_each_online_cpu(j) 93 for_each_online_cpu(j)
89 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j)); 94 seq_printf(p, "%10u ", kstat_irqs_cpu(i, j));
90 seq_printf(p, " %14s", desc->chip->name); 95 seq_printf(p, " %14s", chip->name);
91 seq_printf(p, "-%-8s", desc->name); 96 seq_printf(p, "-%-8s", desc->name);
92 97
93 if (action) { 98 if (action) {
@@ -273,12 +278,6 @@ void __init init_IRQ(void)
273{ 278{
274 plat_irq_setup(); 279 plat_irq_setup();
275 280
276 /*
277 * Pin any of the legacy IRQ vectors that haven't already been
278 * grabbed by the platform
279 */
280 reserve_irq_legacy();
281
282 /* Perform the machine specific initialisation */ 281 /* Perform the machine specific initialisation */
283 if (sh_mv.mv_init_irq) 282 if (sh_mv.mv_init_irq)
284 sh_mv.mv_init_irq(); 283 sh_mv.mv_init_irq();
@@ -297,13 +296,16 @@ int __init arch_probe_nr_irqs(void)
297#endif 296#endif
298 297
299#ifdef CONFIG_HOTPLUG_CPU 298#ifdef CONFIG_HOTPLUG_CPU
300static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu) 299static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu)
301{ 300{
301 struct irq_desc *desc = irq_to_desc(irq);
302 struct irq_chip *chip = irq_data_get_irq_chip(data);
303
302 printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n", 304 printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n",
303 irq, desc->node, cpu); 305 irq, data->node, cpu);
304 306
305 raw_spin_lock_irq(&desc->lock); 307 raw_spin_lock_irq(&desc->lock);
306 desc->chip->set_affinity(irq, cpumask_of(cpu)); 308 chip->irq_set_affinity(data, cpumask_of(cpu), false);
307 raw_spin_unlock_irq(&desc->lock); 309 raw_spin_unlock_irq(&desc->lock);
308} 310}
309 311
@@ -314,24 +316,25 @@ static void route_irq(struct irq_desc *desc, unsigned int irq, unsigned int cpu)
314 */ 316 */
315void migrate_irqs(void) 317void migrate_irqs(void)
316{ 318{
317 struct irq_desc *desc;
318 unsigned int irq, cpu = smp_processor_id(); 319 unsigned int irq, cpu = smp_processor_id();
319 320
320 for_each_irq_desc(irq, desc) { 321 for_each_active_irq(irq) {
321 if (desc->node == cpu) { 322 struct irq_data *data = irq_get_irq_data(irq);
322 unsigned int newcpu = cpumask_any_and(desc->affinity, 323
324 if (data->node == cpu) {
325 unsigned int newcpu = cpumask_any_and(data->affinity,
323 cpu_online_mask); 326 cpu_online_mask);
324 if (newcpu >= nr_cpu_ids) { 327 if (newcpu >= nr_cpu_ids) {
325 if (printk_ratelimit()) 328 if (printk_ratelimit())
326 printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n", 329 printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n",
327 irq, cpu); 330 irq, cpu);
328 331
329 cpumask_setall(desc->affinity); 332 cpumask_setall(data->affinity);
330 newcpu = cpumask_any_and(desc->affinity, 333 newcpu = cpumask_any_and(data->affinity,
331 cpu_online_mask); 334 cpu_online_mask);
332 } 335 }
333 336
334 route_irq(desc, irq, newcpu); 337 route_irq(data, irq, newcpu);
335 } 338 }
336 } 339 }
337} 340}
diff --git a/arch/sh/kernel/irq_64.c b/arch/sh/kernel/irq_64.c
index 32365ba0e039..8fc05b997b6d 100644
--- a/arch/sh/kernel/irq_64.c
+++ b/arch/sh/kernel/irq_64.c
@@ -11,17 +11,17 @@
11#include <linux/module.h> 11#include <linux/module.h>
12#include <cpu/registers.h> 12#include <cpu/registers.h>
13 13
14void notrace raw_local_irq_restore(unsigned long flags) 14void notrace arch_local_irq_restore(unsigned long flags)
15{ 15{
16 unsigned long long __dummy; 16 unsigned long long __dummy;
17 17
18 if (flags == RAW_IRQ_DISABLED) { 18 if (flags == ARCH_IRQ_DISABLED) {
19 __asm__ __volatile__ ( 19 __asm__ __volatile__ (
20 "getcon " __SR ", %0\n\t" 20 "getcon " __SR ", %0\n\t"
21 "or %0, %1, %0\n\t" 21 "or %0, %1, %0\n\t"
22 "putcon %0, " __SR "\n\t" 22 "putcon %0, " __SR "\n\t"
23 : "=&r" (__dummy) 23 : "=&r" (__dummy)
24 : "r" (RAW_IRQ_DISABLED) 24 : "r" (ARCH_IRQ_DISABLED)
25 ); 25 );
26 } else { 26 } else {
27 __asm__ __volatile__ ( 27 __asm__ __volatile__ (
@@ -29,13 +29,13 @@ void notrace raw_local_irq_restore(unsigned long flags)
29 "and %0, %1, %0\n\t" 29 "and %0, %1, %0\n\t"
30 "putcon %0, " __SR "\n\t" 30 "putcon %0, " __SR "\n\t"
31 : "=&r" (__dummy) 31 : "=&r" (__dummy)
32 : "r" (~RAW_IRQ_DISABLED) 32 : "r" (~ARCH_IRQ_DISABLED)
33 ); 33 );
34 } 34 }
35} 35}
36EXPORT_SYMBOL(raw_local_irq_restore); 36EXPORT_SYMBOL(arch_local_irq_restore);
37 37
38unsigned long notrace __raw_local_save_flags(void) 38unsigned long notrace arch_local_save_flags(void)
39{ 39{
40 unsigned long flags; 40 unsigned long flags;
41 41
@@ -43,9 +43,9 @@ unsigned long notrace __raw_local_save_flags(void)
43 "getcon " __SR ", %0\n\t" 43 "getcon " __SR ", %0\n\t"
44 "and %0, %1, %0" 44 "and %0, %1, %0"
45 : "=&r" (flags) 45 : "=&r" (flags)
46 : "r" (RAW_IRQ_DISABLED) 46 : "r" (ARCH_IRQ_DISABLED)
47 ); 47 );
48 48
49 return flags; 49 return flags;
50} 50}
51EXPORT_SYMBOL(__raw_local_save_flags); 51EXPORT_SYMBOL(arch_local_save_flags);
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 4e278467f76c..d6b018c7ebdc 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -41,6 +41,7 @@
41#include <asm/smp.h> 41#include <asm/smp.h>
42#include <asm/mmu_context.h> 42#include <asm/mmu_context.h>
43#include <asm/mmzone.h> 43#include <asm/mmzone.h>
44#include <asm/sparsemem.h>
44 45
45/* 46/*
46 * Initialize loops_per_jiffy as 10000000 (1000MIPS). 47 * Initialize loops_per_jiffy as 10000000 (1000MIPS).
@@ -52,6 +53,7 @@ struct sh_cpuinfo cpu_data[NR_CPUS] __read_mostly = {
52 .type = CPU_SH_NONE, 53 .type = CPU_SH_NONE,
53 .family = CPU_FAMILY_UNKNOWN, 54 .family = CPU_FAMILY_UNKNOWN,
54 .loops_per_jiffy = 10000000, 55 .loops_per_jiffy = 10000000,
56 .phys_bits = MAX_PHYSMEM_BITS,
55 }, 57 },
56}; 58};
57EXPORT_SYMBOL(cpu_data); 59EXPORT_SYMBOL(cpu_data);
@@ -432,6 +434,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
432 if (c->flags & CPU_HAS_L2_CACHE) 434 if (c->flags & CPU_HAS_L2_CACHE)
433 show_cacheinfo(m, "scache", c->scache); 435 show_cacheinfo(m, "scache", c->scache);
434 436
437 seq_printf(m, "address sizes\t: %u bits physical\n", c->phys_bits);
438
435 seq_printf(m, "bogomips\t: %lu.%02lu\n", 439 seq_printf(m, "bogomips\t: %lu.%02lu\n",
436 c->loops_per_jiffy/(500000/HZ), 440 c->loops_per_jiffy/(500000/HZ),
437 (c->loops_per_jiffy/(5000/HZ)) % 100); 441 (c->loops_per_jiffy/(5000/HZ)) % 100);
diff --git a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile
index ab89ea4f9414..150aa326afff 100644
--- a/arch/sh/mm/Makefile
+++ b/arch/sh/mm/Makefile
@@ -15,7 +15,7 @@ cacheops-$(CONFIG_CPU_SHX3) += cache-shx3.o
15obj-y += $(cacheops-y) 15obj-y += $(cacheops-y)
16 16
17mmu-y := nommu.o extable_32.o 17mmu-y := nommu.o extable_32.o
18mmu-$(CONFIG_MMU) := extable_$(BITS).o fault_$(BITS).o \ 18mmu-$(CONFIG_MMU) := extable_$(BITS).o fault_$(BITS).o gup.o \
19 ioremap.o kmap.o pgtable.o tlbflush_$(BITS).o 19 ioremap.o kmap.o pgtable.o tlbflush_$(BITS).o
20 20
21obj-y += $(mmu-y) 21obj-y += $(mmu-y)
diff --git a/arch/sh/mm/gup.c b/arch/sh/mm/gup.c
new file mode 100644
index 000000000000..bf8daf9d9c9b
--- /dev/null
+++ b/arch/sh/mm/gup.c
@@ -0,0 +1,273 @@
1/*
2 * Lockless get_user_pages_fast for SuperH
3 *
4 * Copyright (C) 2009 - 2010 Paul Mundt
5 *
6 * Cloned from the x86 and PowerPC versions, by:
7 *
8 * Copyright (C) 2008 Nick Piggin
9 * Copyright (C) 2008 Novell Inc.
10 */
11#include <linux/sched.h>
12#include <linux/mm.h>
13#include <linux/vmstat.h>
14#include <linux/highmem.h>
15#include <asm/pgtable.h>
16
17static inline pte_t gup_get_pte(pte_t *ptep)
18{
19#ifndef CONFIG_X2TLB
20 return ACCESS_ONCE(*ptep);
21#else
22 /*
23 * With get_user_pages_fast, we walk down the pagetables without
24 * taking any locks. For this we would like to load the pointers
25 * atomically, but that is not possible with 64-bit PTEs. What
26 * we do have is the guarantee that a pte will only either go
27 * from not present to present, or present to not present or both
28 * -- it will not switch to a completely different present page
29 * without a TLB flush in between; something that we are blocking
30 * by holding interrupts off.
31 *
32 * Setting ptes from not present to present goes:
33 * ptep->pte_high = h;
34 * smp_wmb();
35 * ptep->pte_low = l;
36 *
37 * And present to not present goes:
38 * ptep->pte_low = 0;
39 * smp_wmb();
40 * ptep->pte_high = 0;
41 *
42 * We must ensure here that the load of pte_low sees l iff pte_high
43 * sees h. We load pte_high *after* loading pte_low, which ensures we
44 * don't see an older value of pte_high. *Then* we recheck pte_low,
45 * which ensures that we haven't picked up a changed pte high. We might
46 * have got rubbish values from pte_low and pte_high, but we are
47 * guaranteed that pte_low will not have the present bit set *unless*
48 * it is 'l'. And get_user_pages_fast only operates on present ptes, so
49 * we're safe.
50 *
51 * gup_get_pte should not be used or copied outside gup.c without being
52 * very careful -- it does not atomically load the pte or anything that
53 * is likely to be useful for you.
54 */
55 pte_t pte;
56
57retry:
58 pte.pte_low = ptep->pte_low;
59 smp_rmb();
60 pte.pte_high = ptep->pte_high;
61 smp_rmb();
62 if (unlikely(pte.pte_low != ptep->pte_low))
63 goto retry;
64
65 return pte;
66#endif
67}
68
69/*
70 * The performance critical leaf functions are made noinline otherwise gcc
71 * inlines everything into a single function which results in too much
72 * register pressure.
73 */
74static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
75 unsigned long end, int write, struct page **pages, int *nr)
76{
77 u64 mask, result;
78 pte_t *ptep;
79
80#ifdef CONFIG_X2TLB
81 result = _PAGE_PRESENT | _PAGE_EXT(_PAGE_EXT_KERN_READ | _PAGE_EXT_USER_READ);
82 if (write)
83 result |= _PAGE_EXT(_PAGE_EXT_KERN_WRITE | _PAGE_EXT_USER_WRITE);
84#elif defined(CONFIG_SUPERH64)
85 result = _PAGE_PRESENT | _PAGE_USER | _PAGE_READ;
86 if (write)
87 result |= _PAGE_WRITE;
88#else
89 result = _PAGE_PRESENT | _PAGE_USER;
90 if (write)
91 result |= _PAGE_RW;
92#endif
93
94 mask = result | _PAGE_SPECIAL;
95
96 ptep = pte_offset_map(&pmd, addr);
97 do {
98 pte_t pte = gup_get_pte(ptep);
99 struct page *page;
100
101 if ((pte_val(pte) & mask) != result) {
102 pte_unmap(ptep);
103 return 0;
104 }
105 VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
106 page = pte_page(pte);
107 get_page(page);
108 pages[*nr] = page;
109 (*nr)++;
110
111 } while (ptep++, addr += PAGE_SIZE, addr != end);
112 pte_unmap(ptep - 1);
113
114 return 1;
115}
116
117static int gup_pmd_range(pud_t pud, unsigned long addr, unsigned long end,
118 int write, struct page **pages, int *nr)
119{
120 unsigned long next;
121 pmd_t *pmdp;
122
123 pmdp = pmd_offset(&pud, addr);
124 do {
125 pmd_t pmd = *pmdp;
126
127 next = pmd_addr_end(addr, end);
128 if (pmd_none(pmd))
129 return 0;
130 if (!gup_pte_range(pmd, addr, next, write, pages, nr))
131 return 0;
132 } while (pmdp++, addr = next, addr != end);
133
134 return 1;
135}
136
137static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
138 int write, struct page **pages, int *nr)
139{
140 unsigned long next;
141 pud_t *pudp;
142
143 pudp = pud_offset(&pgd, addr);
144 do {
145 pud_t pud = *pudp;
146
147 next = pud_addr_end(addr, end);
148 if (pud_none(pud))
149 return 0;
150 if (!gup_pmd_range(pud, addr, next, write, pages, nr))
151 return 0;
152 } while (pudp++, addr = next, addr != end);
153
154 return 1;
155}
156
157/*
158 * Like get_user_pages_fast() except its IRQ-safe in that it won't fall
159 * back to the regular GUP.
160 */
161int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
162 struct page **pages)
163{
164 struct mm_struct *mm = current->mm;
165 unsigned long addr, len, end;
166 unsigned long next;
167 unsigned long flags;
168 pgd_t *pgdp;
169 int nr = 0;
170
171 start &= PAGE_MASK;
172 addr = start;
173 len = (unsigned long) nr_pages << PAGE_SHIFT;
174 end = start + len;
175 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
176 (void __user *)start, len)))
177 return 0;
178
179 /*
180 * This doesn't prevent pagetable teardown, but does prevent
181 * the pagetables and pages from being freed.
182 */
183 local_irq_save(flags);
184 pgdp = pgd_offset(mm, addr);
185 do {
186 pgd_t pgd = *pgdp;
187
188 next = pgd_addr_end(addr, end);
189 if (pgd_none(pgd))
190 break;
191 if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
192 break;
193 } while (pgdp++, addr = next, addr != end);
194 local_irq_restore(flags);
195
196 return nr;
197}
198
199/**
200 * get_user_pages_fast() - pin user pages in memory
201 * @start: starting user address
202 * @nr_pages: number of pages from start to pin
203 * @write: whether pages will be written to
204 * @pages: array that receives pointers to the pages pinned.
205 * Should be at least nr_pages long.
206 *
207 * Attempt to pin user pages in memory without taking mm->mmap_sem.
208 * If not successful, it will fall back to taking the lock and
209 * calling get_user_pages().
210 *
211 * Returns number of pages pinned. This may be fewer than the number
212 * requested. If nr_pages is 0 or negative, returns 0. If no pages
213 * were pinned, returns -errno.
214 */
215int get_user_pages_fast(unsigned long start, int nr_pages, int write,
216 struct page **pages)
217{
218 struct mm_struct *mm = current->mm;
219 unsigned long addr, len, end;
220 unsigned long next;
221 pgd_t *pgdp;
222 int nr = 0;
223
224 start &= PAGE_MASK;
225 addr = start;
226 len = (unsigned long) nr_pages << PAGE_SHIFT;
227
228 end = start + len;
229 if (end < start)
230 goto slow_irqon;
231
232 local_irq_disable();
233 pgdp = pgd_offset(mm, addr);
234 do {
235 pgd_t pgd = *pgdp;
236
237 next = pgd_addr_end(addr, end);
238 if (pgd_none(pgd))
239 goto slow;
240 if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
241 goto slow;
242 } while (pgdp++, addr = next, addr != end);
243 local_irq_enable();
244
245 VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT);
246 return nr;
247
248 {
249 int ret;
250
251slow:
252 local_irq_enable();
253slow_irqon:
254 /* Try to get the remaining pages with get_user_pages */
255 start += nr << PAGE_SHIFT;
256 pages += nr;
257
258 down_read(&mm->mmap_sem);
259 ret = get_user_pages(current, mm, start,
260 (end - start) >> PAGE_SHIFT, write, 0, pages, NULL);
261 up_read(&mm->mmap_sem);
262
263 /* Have to be a bit careful with return values */
264 if (nr > 0) {
265 if (ret < 0)
266 ret = nr;
267 else
268 ret += nr;
269 }
270
271 return ret;
272 }
273}
diff --git a/arch/sh/oprofile/Makefile b/arch/sh/oprofile/Makefile
index e85aae73e3dc..ce3b119021e7 100644
--- a/arch/sh/oprofile/Makefile
+++ b/arch/sh/oprofile/Makefile
@@ -1,5 +1,7 @@
1obj-$(CONFIG_OPROFILE) += oprofile.o 1obj-$(CONFIG_OPROFILE) += oprofile.o
2 2
3CFLAGS_common.o += -DUTS_MACHINE='"$(UTS_MACHINE)"'
4
3DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ 5DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
4 oprof.o cpu_buffer.o buffer_sync.o \ 6 oprof.o cpu_buffer.o buffer_sync.o \
5 event_buffer.o oprofile_files.o \ 7 event_buffer.o oprofile_files.o \
diff --git a/arch/sh/oprofile/backtrace.c b/arch/sh/oprofile/backtrace.c
index 2bc74de23f08..37f3a75ea6cb 100644
--- a/arch/sh/oprofile/backtrace.c
+++ b/arch/sh/oprofile/backtrace.c
@@ -91,7 +91,7 @@ void sh_backtrace(struct pt_regs * const regs, unsigned int depth)
91 if (depth > backtrace_limit) 91 if (depth > backtrace_limit)
92 depth = backtrace_limit; 92 depth = backtrace_limit;
93 93
94 stackaddr = (unsigned long *)regs->regs[15]; 94 stackaddr = (unsigned long *)kernel_stack_pointer(regs);
95 if (!user_mode(regs)) { 95 if (!user_mode(regs)) {
96 if (depth) 96 if (depth)
97 unwind_stack(NULL, regs, stackaddr, 97 unwind_stack(NULL, regs, stackaddr,
diff --git a/arch/sh/oprofile/common.c b/arch/sh/oprofile/common.c
index e10d89376f9b..b4c2d2b946dd 100644
--- a/arch/sh/oprofile/common.c
+++ b/arch/sh/oprofile/common.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/oprofile/init.c 2 * arch/sh/oprofile/init.c
3 * 3 *
4 * Copyright (C) 2003 - 2008 Paul Mundt 4 * Copyright (C) 2003 - 2010 Paul Mundt
5 * 5 *
6 * Based on arch/mips/oprofile/common.c: 6 * Based on arch/mips/oprofile/common.c:
7 * 7 *
@@ -18,43 +18,46 @@
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/smp.h> 19#include <linux/smp.h>
20#include <linux/perf_event.h> 20#include <linux/perf_event.h>
21#include <linux/slab.h>
21#include <asm/processor.h> 22#include <asm/processor.h>
22 23
23#ifdef CONFIG_HW_PERF_EVENTS
24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth); 24extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
25 25
26#ifdef CONFIG_HW_PERF_EVENTS
27/*
28 * This will need to be reworked when multiple PMUs are supported.
29 */
30static char *sh_pmu_op_name;
31
26char *op_name_from_perf_id(void) 32char *op_name_from_perf_id(void)
27{ 33{
28 const char *pmu; 34 return sh_pmu_op_name;
29 char buf[20];
30 int size;
31
32 pmu = perf_pmu_name();
33 if (!pmu)
34 return NULL;
35
36 size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
37 if (size > -1 && size < sizeof(buf))
38 return buf;
39
40 return NULL;
41} 35}
42 36
43int __init oprofile_arch_init(struct oprofile_operations *ops) 37int __init oprofile_arch_init(struct oprofile_operations *ops)
44{ 38{
45 ops->backtrace = sh_backtrace; 39 ops->backtrace = sh_backtrace;
46 40
41 if (perf_num_counters() == 0)
42 return -ENODEV;
43
44 sh_pmu_op_name = kasprintf(GFP_KERNEL, "%s/%s",
45 UTS_MACHINE, perf_pmu_name());
46 if (unlikely(!sh_pmu_op_name))
47 return -ENOMEM;
48
47 return oprofile_perf_init(ops); 49 return oprofile_perf_init(ops);
48} 50}
49 51
50void __exit oprofile_arch_exit(void) 52void __exit oprofile_arch_exit(void)
51{ 53{
52 oprofile_perf_exit(); 54 oprofile_perf_exit();
55 kfree(sh_pmu_op_name);
53} 56}
54#else 57#else
55int __init oprofile_arch_init(struct oprofile_operations *ops) 58int __init oprofile_arch_init(struct oprofile_operations *ops)
56{ 59{
57 pr_info("oprofile: hardware counters not available\n"); 60 ops->backtrace = sh_backtrace;
58 return -ENODEV; 61 return -ENODEV;
59} 62}
60void __exit oprofile_arch_exit(void) {} 63void __exit oprofile_arch_exit(void) {}