Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[safe/jmp/linux-2.6] / arch / sh / kernel / perf_event.c
index d151070..9f253e9 100644 (file)
@@ -103,7 +103,7 @@ static int __hw_perf_event_init(struct perf_event *event)
 {
        struct perf_event_attr *attr = &event->attr;
        struct hw_perf_event *hwc = &event->hw;
-       int config;
+       int config = -1;
        int err;
 
        if (!sh_pmu_initialized())
@@ -155,8 +155,6 @@ static int __hw_perf_event_init(struct perf_event *event)
 
                config = sh_pmu->event_map(attr->config);
                break;
-       default:
-               return -EINVAL;
        }
 
        if (config == -1)
@@ -277,13 +275,30 @@ const struct pmu *hw_perf_event_init(struct perf_event *event)
        return &pmu;
 }
 
-void hw_perf_event_setup(int cpu)
+static void sh_pmu_setup(int cpu)
 {
        struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu);
 
        memset(cpuhw, 0, sizeof(struct cpu_hw_events));
 }
 
+static int __cpuinit
+sh_pmu_notifier(struct notifier_block *self, unsigned long action, void *hcpu)
+{
+       unsigned int cpu = (long)hcpu;
+
+       switch (action & ~CPU_TASKS_FROZEN) {
+       case CPU_UP_PREPARE:
+               sh_pmu_setup(cpu);
+               break;
+
+       default:
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 void hw_perf_enable(void)
 {
        if (!sh_pmu_initialized())
@@ -308,7 +323,8 @@ int register_sh_pmu(struct sh_pmu *pmu)
 
        pr_info("Performance Events: %s support registered\n", pmu->name);
 
-       WARN_ON(pmu->num_events >= MAX_HWEVENTS);
+       WARN_ON(pmu->num_events > MAX_HWEVENTS);
 
+       perf_cpu_notifier(sh_pmu_notifier);
        return 0;
 }