aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-08-17 02:26:01 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-19 02:26:18 -0400
commit73a6b0538c131d489fe7a2581deddb72faca496b (patch)
tree3d74b564d96900134d168eff200f802970fb7d70 /arch/sparc/kernel
parent09d053c797f4a559af0647e4283b9b9ec0682d10 (diff)
sparc64: Abstract away the NMI PIC counter computation.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/nmi.c6
-rw-r--r--arch/sparc/kernel/pcr.c18
2 files changed, 19 insertions, 5 deletions
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
index ef22b9bacf1..4c45158d4c8 100644
--- a/arch/sparc/kernel/nmi.c
+++ b/arch/sparc/kernel/nmi.c
@@ -125,7 +125,7 @@ notrace __kprobes void perfctr_irq(int irq, struct pt_regs *regs)
125 __this_cpu_write(alert_counter, 0); 125 __this_cpu_write(alert_counter, 0);
126 } 126 }
127 if (__get_cpu_var(wd_enabled)) { 127 if (__get_cpu_var(wd_enabled)) {
128 pcr_ops->write_pic(0, picl_value(nmi_hz)); 128 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
129 pcr_ops->write_pcr(0, pcr_enable); 129 pcr_ops->write_pcr(0, pcr_enable);
130 } 130 }
131 131
@@ -223,7 +223,7 @@ void start_nmi_watchdog(void *unused)
223 atomic_inc(&nmi_active); 223 atomic_inc(&nmi_active);
224 224
225 pcr_ops->write_pcr(0, PCR_PIC_PRIV); 225 pcr_ops->write_pcr(0, PCR_PIC_PRIV);
226 pcr_ops->write_pic(0, picl_value(nmi_hz)); 226 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
227 227
228 pcr_ops->write_pcr(0, pcr_enable); 228 pcr_ops->write_pcr(0, pcr_enable);
229} 229}
@@ -234,7 +234,7 @@ static void nmi_adjust_hz_one(void *unused)
234 return; 234 return;
235 235
236 pcr_ops->write_pcr(0, PCR_PIC_PRIV); 236 pcr_ops->write_pcr(0, PCR_PIC_PRIV);
237 pcr_ops->write_pic(0, picl_value(nmi_hz)); 237 pcr_ops->write_pic(0, pcr_ops->nmi_picl_value(nmi_hz));
238 238
239 pcr_ops->write_pcr(0, pcr_enable); 239 pcr_ops->write_pcr(0, pcr_enable);
240} 240}
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
index e82ae89666f..494af3227f3 100644
--- a/arch/sparc/kernel/pcr.c
+++ b/arch/sparc/kernel/pcr.c
@@ -27,7 +27,6 @@
27 (0xff << PCR_N2_MASK1_SHIFT)) 27 (0xff << PCR_N2_MASK1_SHIFT))
28 28
29u64 pcr_enable; 29u64 pcr_enable;
30unsigned int picl_shift;
31 30
32/* Performance counter interrupts run unmasked at PIL level 15. 31/* Performance counter interrupts run unmasked at PIL level 15.
33 * Therefore we can't do things like wakeups and other work 32 * Therefore we can't do things like wakeups and other work
@@ -98,11 +97,19 @@ static void direct_pic_write(unsigned long reg_num, u64 val)
98 "rd %%pic, %%g0" : : "r" (val)); 97 "rd %%pic, %%g0" : : "r" (val));
99} 98}
100 99
100static u64 direct_picl_value(unsigned int nmi_hz)
101{
102 u32 delta = local_cpu_data().clock_tick / nmi_hz;
103
104 return ((u64)((0 - delta) & 0xffffffff)) << 32;
105}
106
101static const struct pcr_ops direct_pcr_ops = { 107static const struct pcr_ops direct_pcr_ops = {
102 .read_pcr = direct_pcr_read, 108 .read_pcr = direct_pcr_read,
103 .write_pcr = direct_pcr_write, 109 .write_pcr = direct_pcr_write,
104 .read_pic = direct_pic_read, 110 .read_pic = direct_pic_read,
105 .write_pic = direct_pic_write, 111 .write_pic = direct_pic_write,
112 .nmi_picl_value = direct_picl_value,
106}; 113};
107 114
108static void n2_pcr_write(unsigned long reg_num, u64 val) 115static void n2_pcr_write(unsigned long reg_num, u64 val)
@@ -118,11 +125,19 @@ static void n2_pcr_write(unsigned long reg_num, u64 val)
118 direct_pcr_write(reg_num, val); 125 direct_pcr_write(reg_num, val);
119} 126}
120 127
128static u64 n2_picl_value(unsigned int nmi_hz)
129{
130 u32 delta = local_cpu_data().clock_tick / (nmi_hz << 2);
131
132 return ((u64)((0 - delta) & 0xffffffff)) << 32;
133}
134
121static const struct pcr_ops n2_pcr_ops = { 135static const struct pcr_ops n2_pcr_ops = {
122 .read_pcr = direct_pcr_read, 136 .read_pcr = direct_pcr_read,
123 .write_pcr = n2_pcr_write, 137 .write_pcr = n2_pcr_write,
124 .read_pic = direct_pic_read, 138 .read_pic = direct_pic_read,
125 .write_pic = direct_pic_write, 139 .write_pic = direct_pic_write,
140 .nmi_picl_value = n2_picl_value,
126}; 141};
127 142
128static unsigned long perf_hsvc_group; 143static unsigned long perf_hsvc_group;
@@ -180,7 +195,6 @@ int __init pcr_arch_init(void)
180 case hypervisor: 195 case hypervisor:
181 pcr_ops = &n2_pcr_ops; 196 pcr_ops = &n2_pcr_ops;
182 pcr_enable = PCR_N2_ENABLE; 197 pcr_enable = PCR_N2_ENABLE;
183 picl_shift = 2;
184 break; 198 break;
185 199
186 case cheetah: 200 case cheetah: