~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to arch/x86/kernel/cpu/perf_event_p4.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Netburst Perfomance Events (P4, old Xeon)
 
2
 * Netburst Performance Events (P4, old Xeon)
3
3
 *
4
4
 *  Copyright (C) 2010 Parallels, Inc., Cyrill Gorcunov <gorcunov@openvz.org>
5
5
 *  Copyright (C) 2010 Intel Corporation, Lin Ming <ming.m.lin@intel.com>
468
468
                .opcode         = P4_OPCODE(P4_EVENT_MISPRED_BRANCH_RETIRED),
469
469
                .escr_msr       = { MSR_P4_CRU_ESCR0, MSR_P4_CRU_ESCR1 },
470
470
                .escr_emask     =
471
 
                P4_ESCR_EMASK_BIT(P4_EVENT_MISPRED_BRANCH_RETIRED, NBOGUS),
 
471
                        P4_ESCR_EMASK_BIT(P4_EVENT_MISPRED_BRANCH_RETIRED, NBOGUS),
472
472
                .cntr           = { {12, 13, 16}, {14, 15, 17} },
473
473
        },
474
474
        [P4_EVENT_X87_ASSIST] = {
679
679
         */
680
680
 
681
681
        /*
682
 
         * if an event is shared accross the logical threads
 
682
         * if an event is shared across the logical threads
683
683
         * the user needs special permissions to be able to use it
684
684
         */
685
685
        if (p4_ht_active() && p4_event_bind_map[v].shared) {
764
764
        u64 v;
765
765
 
766
766
        /* an official way for overflow indication */
767
 
        rdmsrl(hwc->config_base + hwc->idx, v);
 
767
        rdmsrl(hwc->config_base, v);
768
768
        if (v & P4_CCCR_OVF) {
769
 
                wrmsrl(hwc->config_base + hwc->idx, v & ~P4_CCCR_OVF);
 
769
                wrmsrl(hwc->config_base, v & ~P4_CCCR_OVF);
770
770
                return 1;
771
771
        }
772
772
 
777
777
         * the counter has reached zero value and continued counting before
778
778
         * real NMI signal was received:
779
779
         */
 
780
        rdmsrl(hwc->event_base, v);
780
781
        if (!(v & ARCH_P4_UNFLAGGED_BIT))
781
782
                return 1;
782
783
 
790
791
         *
791
792
         * It's still allowed that two threads setup same cache
792
793
         * events so we can't simply clear metrics until we knew
793
 
         * noone is depending on us, so we need kind of counter
 
794
         * no one is depending on us, so we need kind of counter
794
795
         * for "ReplayEvent" users.
795
796
         *
796
797
         * What is more complex -- RAW events, if user (for some
797
798
         * reason) will pass some cache event metric with improper
798
799
         * event opcode -- it's fine from hardware point of view
799
 
         * but completely nonsence from "meaning" of such action.
 
800
         * but completely nonsense from "meaning" of such action.
800
801
         *
801
802
         * So at moment let leave metrics turned on forever -- it's
802
803
         * ok for now but need to be revisited!
815
816
         * state we need to clear P4_CCCR_OVF, otherwise interrupt get
816
817
         * asserted again and again
817
818
         */
818
 
        (void)checking_wrmsrl(hwc->config_base + hwc->idx,
 
819
        (void)checking_wrmsrl(hwc->config_base,
819
820
                (u64)(p4_config_unpack_cccr(hwc->config)) &
820
821
                        ~P4_CCCR_ENABLE & ~P4_CCCR_OVF & ~P4_CCCR_RESERVED);
821
822
}
885
886
        p4_pmu_enable_pebs(hwc->config);
886
887
 
887
888
        (void)checking_wrmsrl(escr_addr, escr_conf);
888
 
        (void)checking_wrmsrl(hwc->config_base + hwc->idx,
 
889
        (void)checking_wrmsrl(hwc->config_base,
889
890
                                (cccr & ~P4_CCCR_RESERVED) | P4_CCCR_ENABLE);
890
891
}
891
892
 
911
912
        int idx, handled = 0;
912
913
        u64 val;
913
914
 
914
 
        data.addr = 0;
915
 
        data.raw = NULL;
 
915
        perf_sample_data_init(&data, 0);
916
916
 
917
917
        cpuc = &__get_cpu_var(cpu_hw_events);
918
918
 
946
946
                if (!x86_perf_event_set_period(event))
947
947
                        continue;
948
948
                if (perf_event_overflow(event, 1, &data, regs))
949
 
                        p4_pmu_disable_event(event);
 
949
                        x86_pmu_stop(event, 0);
950
950
        }
951
951
 
952
 
        if (handled) {
953
 
                /* p4 quirk: unmask it again */
954
 
                apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED);
 
952
        if (handled)
955
953
                inc_irq_stat(apic_perf_irqs);
956
 
        }
 
954
 
 
955
        /*
 
956
         * When dealing with the unmasking of the LVTPC on P4 perf hw, it has
 
957
         * been observed that the OVF bit flag has to be cleared first _before_
 
958
         * the LVTPC can be unmasked.
 
959
         *
 
960
         * The reason is the NMI line will continue to be asserted while the OVF
 
961
         * bit is set.  This causes a second NMI to generate if the LVTPC is
 
962
         * unmasked before the OVF bit is cleared, leading to unknown NMI
 
963
         * messages.
 
964
         */
 
965
        apic_write(APIC_LVTPC, APIC_DM_NMI);
957
966
 
958
967
        return handled;
959
968
}
1187
1196
{
1188
1197
        unsigned int low, high;
1189
1198
 
1190
 
        /* If we get stripped -- indexig fails */
 
1199
        /* If we get stripped -- indexing fails */
1191
1200
        BUILD_BUG_ON(ARCH_P4_MAX_CCCR > X86_PMC_MAX_GENERIC);
1192
1201
 
1193
1202
        rdmsr(MSR_IA32_MISC_ENABLE, low, high);