aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-08-17 00:16:22 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-19 02:04:08 -0400
commit0bab20ba4c95f56355c24a0b9f03eb486c2a267d (patch)
tree906d0ca27a6c62ea01b55e24f7a4c3a7e76a723e
parent8c79bfa51101354853f0f5d3b02435cec429da51 (diff)
sparc64: Add 'reg_num' argument to pcr_ops methods.
SPARC-T4 and later have multiple PCR registers, one for each PIC counter. Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/include/asm/pcr.h4
-rw-r--r--arch/sparc/kernel/nmi.c14
-rw-r--r--arch/sparc/kernel/pcr.c9
-rw-r--r--arch/sparc/kernel/perf_event.c14
4 files changed, 22 insertions, 19 deletions
diff --git a/arch/sparc/include/asm/pcr.h b/arch/sparc/include/asm/pcr.h
index 288d7beba051..55e23416eefc 100644
--- a/arch/sparc/include/asm/pcr.h
+++ b/arch/sparc/include/asm/pcr.h
@@ -2,8 +2,8 @@
2#define __PCR_H 2#define __PCR_H
3 3
4struct pcr_ops { 4struct pcr_ops {
5 u64 (*read)(void); 5 u64 (*read)(unsigned long);
6 void (*write)(u64); 6 void (*write)(unsigned long, u64);
7}; 7};
8extern const struct pcr_ops *pcr_ops; 8extern const struct pcr_ops *pcr_ops;
9 9
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
index eb1c1f010a47..95df720a14a9 100644
--- a/arch/sparc/kernel/nmi.c
+++ b/arch/sparc/kernel/nmi.c
@@ -109,7 +109,7 @@ notrace __kprobes void perfctr_irq(int irq, struct pt_regs *regs)
109 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP) 109 pt_regs_trap_type(regs), SIGINT) == NOTIFY_STOP)
110 touched = 1; 110 touched = 1;
111 else 111 else
112 pcr_ops->write(PCR_PIC_PRIV); 112 pcr_ops->write(0, PCR_PIC_PRIV);
113 113
114 sum = local_cpu_data().irq0_irqs; 114 sum = local_cpu_data().irq0_irqs;
115 if (__get_cpu_var(nmi_touch)) { 115 if (__get_cpu_var(nmi_touch)) {
@@ -127,7 +127,7 @@ notrace __kprobes void perfctr_irq(int irq, struct pt_regs *regs)
127 } 127 }
128 if (__get_cpu_var(wd_enabled)) { 128 if (__get_cpu_var(wd_enabled)) {
129 write_pic(picl_value(nmi_hz)); 129 write_pic(picl_value(nmi_hz));
130 pcr_ops->write(pcr_enable); 130 pcr_ops->write(0, pcr_enable);
131 } 131 }
132 132
133 restore_hardirq_stack(orig_sp); 133 restore_hardirq_stack(orig_sp);
@@ -166,7 +166,7 @@ static void report_broken_nmi(int cpu, int *prev_nmi_count)
166 166
167void stop_nmi_watchdog(void *unused) 167void stop_nmi_watchdog(void *unused)
168{ 168{
169 pcr_ops->write(PCR_PIC_PRIV); 169 pcr_ops->write(0, PCR_PIC_PRIV);
170 __get_cpu_var(wd_enabled) = 0; 170 __get_cpu_var(wd_enabled) = 0;
171 atomic_dec(&nmi_active); 171 atomic_dec(&nmi_active);
172} 172}
@@ -223,10 +223,10 @@ void start_nmi_watchdog(void *unused)
223 __get_cpu_var(wd_enabled) = 1; 223 __get_cpu_var(wd_enabled) = 1;
224 atomic_inc(&nmi_active); 224 atomic_inc(&nmi_active);
225 225
226 pcr_ops->write(PCR_PIC_PRIV); 226 pcr_ops->write(0, PCR_PIC_PRIV);
227 write_pic(picl_value(nmi_hz)); 227 write_pic(picl_value(nmi_hz));
228 228
229 pcr_ops->write(pcr_enable); 229 pcr_ops->write(0, pcr_enable);
230} 230}
231 231
232static void nmi_adjust_hz_one(void *unused) 232static void nmi_adjust_hz_one(void *unused)
@@ -234,10 +234,10 @@ static void nmi_adjust_hz_one(void *unused)
234 if (!__get_cpu_var(wd_enabled)) 234 if (!__get_cpu_var(wd_enabled))
235 return; 235 return;
236 236
237 pcr_ops->write(PCR_PIC_PRIV); 237 pcr_ops->write(0, PCR_PIC_PRIV);
238 write_pic(picl_value(nmi_hz)); 238 write_pic(picl_value(nmi_hz));
239 239
240 pcr_ops->write(pcr_enable); 240 pcr_ops->write(0, pcr_enable);
241} 241}
242 242
243void nmi_adjust_hz(unsigned int new_hz) 243void nmi_adjust_hz(unsigned int new_hz)
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
index 0ce0dd2332aa..3d9ab5be23d8 100644
--- a/arch/sparc/kernel/pcr.c
+++ b/arch/sparc/kernel/pcr.c
@@ -60,16 +60,18 @@ void arch_irq_work_raise(void)
60const struct pcr_ops *pcr_ops; 60const struct pcr_ops *pcr_ops;
61EXPORT_SYMBOL_GPL(pcr_ops); 61EXPORT_SYMBOL_GPL(pcr_ops);
62 62
63static u64 direct_pcr_read(void) 63static u64 direct_pcr_read(unsigned long reg_num)
64{ 64{
65 u64 val; 65 u64 val;
66 66
67 WARN_ON_ONCE(reg_num != 0);
67 read_pcr(val); 68 read_pcr(val);
68 return val; 69 return val;
69} 70}
70 71
71static void direct_pcr_write(u64 val) 72static void direct_pcr_write(unsigned long reg_num, u64 val)
72{ 73{
74 WARN_ON_ONCE(reg_num != 0);
73 write_pcr(val); 75 write_pcr(val);
74} 76}
75 77
@@ -78,10 +80,11 @@ static const struct pcr_ops direct_pcr_ops = {
78 .write = direct_pcr_write, 80 .write = direct_pcr_write,
79}; 81};
80 82
81static void n2_pcr_write(u64 val) 83static void n2_pcr_write(unsigned long reg_num, u64 val)
82{ 84{
83 unsigned long ret; 85 unsigned long ret;
84 86
87 WARN_ON_ONCE(reg_num != 0);
85 if (val & PCR_N2_HTRACE) { 88 if (val & PCR_N2_HTRACE) {
86 ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val); 89 ret = sun4v_niagara2_setperf(HV_N2_PERF_SPARC_CTL, val);
87 if (ret != HV_EOK) 90 if (ret != HV_EOK)
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 5713957dcb8a..e1c9848c39cb 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -564,7 +564,7 @@ static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_
564 val |= hwc->config; 564 val |= hwc->config;
565 cpuc->pcr = val; 565 cpuc->pcr = val;
566 566
567 pcr_ops->write(cpuc->pcr); 567 pcr_ops->write(0, cpuc->pcr);
568} 568}
569 569
570static inline void sparc_pmu_disable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx) 570static inline void sparc_pmu_disable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx)
@@ -578,7 +578,7 @@ static inline void sparc_pmu_disable_event(struct cpu_hw_events *cpuc, struct hw
578 val |= nop; 578 val |= nop;
579 cpuc->pcr = val; 579 cpuc->pcr = val;
580 580
581 pcr_ops->write(cpuc->pcr); 581 pcr_ops->write(0, cpuc->pcr);
582} 582}
583 583
584static u32 read_pmc(int idx) 584static u32 read_pmc(int idx)
@@ -736,7 +736,7 @@ static void sparc_pmu_enable(struct pmu *pmu)
736 cpuc->pcr = pcr | cpuc->event[0]->hw.config_base; 736 cpuc->pcr = pcr | cpuc->event[0]->hw.config_base;
737 } 737 }
738 738
739 pcr_ops->write(cpuc->pcr); 739 pcr_ops->write(0, cpuc->pcr);
740} 740}
741 741
742static void sparc_pmu_disable(struct pmu *pmu) 742static void sparc_pmu_disable(struct pmu *pmu)
@@ -755,7 +755,7 @@ static void sparc_pmu_disable(struct pmu *pmu)
755 sparc_pmu->hv_bit | sparc_pmu->irq_bit); 755 sparc_pmu->hv_bit | sparc_pmu->irq_bit);
756 cpuc->pcr = val; 756 cpuc->pcr = val;
757 757
758 pcr_ops->write(cpuc->pcr); 758 pcr_ops->write(0, cpuc->pcr);
759} 759}
760 760
761static int active_event_index(struct cpu_hw_events *cpuc, 761static int active_event_index(struct cpu_hw_events *cpuc,
@@ -856,7 +856,7 @@ static void perf_stop_nmi_watchdog(void *unused)
856 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events); 856 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
857 857
858 stop_nmi_watchdog(NULL); 858 stop_nmi_watchdog(NULL);
859 cpuc->pcr = pcr_ops->read(); 859 cpuc->pcr = pcr_ops->read(0);
860} 860}
861 861
862void perf_event_grab_pmc(void) 862void perf_event_grab_pmc(void)
@@ -1264,7 +1264,7 @@ void perf_event_print_debug(void)
1264 1264
1265 cpu = smp_processor_id(); 1265 cpu = smp_processor_id();
1266 1266
1267 pcr = pcr_ops->read(); 1267 pcr = pcr_ops->read(0);
1268 read_pic(pic); 1268 read_pic(pic);
1269 1269
1270 pr_info("\n"); 1270 pr_info("\n");
@@ -1306,7 +1306,7 @@ static int __kprobes perf_event_nmi_handler(struct notifier_block *self,
1306 * overflow so we don't lose any events. 1306 * overflow so we don't lose any events.
1307 */ 1307 */
1308 if (sparc_pmu->irq_bit) 1308 if (sparc_pmu->irq_bit)
1309 pcr_ops->write(cpuc->pcr); 1309 pcr_ops->write(0, cpuc->pcr);
1310 1310
1311 for (i = 0; i < cpuc->n_events; i++) { 1311 for (i = 0; i < cpuc->n_events; i++) {
1312 struct perf_event *event = cpuc->event[i]; 1312 struct perf_event *event = cpuc->event[i];