Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf/x86/intel/uncore: Add filter support for QPI boxes

The QPI uncore boxes have two pairs of MATCH/MASK registers that
user to filter packet traffic serviced by QPI link layer. These
registers are in auxiliary PCI devices.

This patch adds the auxiliary PCI devices to snbep_uncore_pci_ids
and adds field definitions for the MATCH/MASK registers.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1375856245-10717-2-git-send-email-zheng.z.yan@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Yan, Zheng and committed by
Ingo Molnar
fd1ec259 899396cf

+123 -18
+122 -17
arch/x86/kernel/cpu/perf_event_intel_uncore.c
··· 47 47 DEFINE_UNCORE_FORMAT_ATTR(filter_band1, filter_band1, "config1:8-15"); 48 48 DEFINE_UNCORE_FORMAT_ATTR(filter_band2, filter_band2, "config1:16-23"); 49 49 DEFINE_UNCORE_FORMAT_ATTR(filter_band3, filter_band3, "config1:24-31"); 50 + DEFINE_UNCORE_FORMAT_ATTR(match_rds, match_rds, "config1:48-51"); 51 + DEFINE_UNCORE_FORMAT_ATTR(match_rnid30, match_rnid30, "config1:32-35"); 52 + DEFINE_UNCORE_FORMAT_ATTR(match_rnid4, match_rnid4, "config1:31"); 53 + DEFINE_UNCORE_FORMAT_ATTR(match_dnid, match_dnid, "config1:13-17"); 54 + DEFINE_UNCORE_FORMAT_ATTR(match_mc, match_mc, "config1:9-12"); 55 + DEFINE_UNCORE_FORMAT_ATTR(match_opc, match_opc, "config1:5-8"); 56 + DEFINE_UNCORE_FORMAT_ATTR(match_vnw, match_vnw, "config1:3-4"); 57 + DEFINE_UNCORE_FORMAT_ATTR(match0, match0, "config1:0-31"); 58 + DEFINE_UNCORE_FORMAT_ATTR(match1, match1, "config1:32-63"); 59 + DEFINE_UNCORE_FORMAT_ATTR(mask_rds, mask_rds, "config2:48-51"); 60 + DEFINE_UNCORE_FORMAT_ATTR(mask_rnid30, mask_rnid30, "config2:32-35"); 61 + DEFINE_UNCORE_FORMAT_ATTR(mask_rnid4, mask_rnid4, "config2:31"); 62 + DEFINE_UNCORE_FORMAT_ATTR(mask_dnid, mask_dnid, "config2:13-17"); 63 + DEFINE_UNCORE_FORMAT_ATTR(mask_mc, mask_mc, "config2:9-12"); 64 + DEFINE_UNCORE_FORMAT_ATTR(mask_opc, mask_opc, "config2:5-8"); 65 + DEFINE_UNCORE_FORMAT_ATTR(mask_vnw, mask_vnw, "config2:3-4"); 66 + DEFINE_UNCORE_FORMAT_ATTR(mask0, mask0, "config2:0-31"); 67 + DEFINE_UNCORE_FORMAT_ATTR(mask1, mask1, "config2:32-63"); 50 68 51 69 static u64 uncore_msr_read_counter(struct intel_uncore_box *box, struct perf_event *event) 52 70 { ··· 321 303 &format_attr_edge.attr, 322 304 &format_attr_inv.attr, 323 305 &format_attr_thresh8.attr, 306 + &format_attr_match_rds.attr, 307 + &format_attr_match_rnid30.attr, 308 + &format_attr_match_rnid4.attr, 309 + &format_attr_match_dnid.attr, 310 + &format_attr_match_mc.attr, 311 + &format_attr_match_opc.attr, 312 + &format_attr_match_vnw.attr, 313 + &format_attr_match0.attr, 314 + &format_attr_match1.attr, 315 + &format_attr_mask_rds.attr, 316 + &format_attr_mask_rnid30.attr, 317 + &format_attr_mask_rnid4.attr, 318 + &format_attr_mask_dnid.attr, 319 + &format_attr_mask_mc.attr, 320 + &format_attr_mask_opc.attr, 321 + &format_attr_mask_vnw.attr, 322 + &format_attr_mask0.attr, 323 + &format_attr_mask1.attr, 324 324 NULL, 325 325 }; 326 326 ··· 394 358 SNBEP_UNCORE_MSR_OPS_COMMON_INIT(), 395 359 }; 396 360 361 + #define SNBEP_UNCORE_PCI_OPS_COMMON_INIT() \ 362 + .init_box = snbep_uncore_pci_init_box, \ 363 + .disable_box = snbep_uncore_pci_disable_box, \ 364 + .enable_box = snbep_uncore_pci_enable_box, \ 365 + .disable_event = snbep_uncore_pci_disable_event, \ 366 + .read_counter = snbep_uncore_pci_read_counter 367 + 397 368 static struct intel_uncore_ops snbep_uncore_pci_ops = { 398 - .init_box = snbep_uncore_pci_init_box, 399 - .disable_box = snbep_uncore_pci_disable_box, 400 - .enable_box = snbep_uncore_pci_enable_box, 401 - .disable_event = snbep_uncore_pci_disable_event, 402 - .enable_event = snbep_uncore_pci_enable_event, 403 - .read_counter = snbep_uncore_pci_read_counter, 369 + SNBEP_UNCORE_PCI_OPS_COMMON_INIT(), 370 + .enable_event = snbep_uncore_pci_enable_event, \ 404 371 }; 405 372 406 373 static struct event_constraint snbep_uncore_cbox_constraints[] = { ··· 767 728 NULL, 768 729 }; 769 730 731 + enum { 732 + SNBEP_PCI_QPI_PORT0_FILTER, 733 + SNBEP_PCI_QPI_PORT1_FILTER, 734 + }; 735 + 736 + static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event) 737 + { 738 + struct hw_perf_event *hwc = &event->hw; 739 + struct hw_perf_event_extra *reg1 = &hwc->extra_reg; 740 + struct hw_perf_event_extra *reg2 = &hwc->branch_reg; 741 + 742 + if ((hwc->config & SNBEP_PMON_CTL_EV_SEL_MASK) == 0x38) { 743 + reg1->idx = 0; 744 + reg1->reg = SNBEP_Q_Py_PCI_PMON_PKT_MATCH0; 745 + reg1->config = event->attr.config1; 746 + reg2->reg = SNBEP_Q_Py_PCI_PMON_PKT_MASK0; 747 + reg2->config = event->attr.config2; 748 + } 749 + return 0; 750 + } 751 + 752 + static void snbep_qpi_enable_event(struct intel_uncore_box *box, struct perf_event *event) 753 + { 754 + struct pci_dev *pdev = box->pci_dev; 755 + struct hw_perf_event *hwc = &event->hw; 756 + struct hw_perf_event_extra *reg1 = &hwc->extra_reg; 757 + struct hw_perf_event_extra *reg2 = &hwc->branch_reg; 758 + 759 + if (reg1->idx != EXTRA_REG_NONE) { 760 + int idx = box->pmu->pmu_idx + SNBEP_PCI_QPI_PORT0_FILTER; 761 + struct pci_dev *filter_pdev = extra_pci_dev[box->phys_id][idx]; 762 + WARN_ON_ONCE(!filter_pdev); 763 + if (filter_pdev) { 764 + pci_write_config_dword(filter_pdev, reg1->reg, 765 + (u32)reg1->config); 766 + pci_write_config_dword(filter_pdev, reg1->reg + 4, 767 + (u32)(reg1->config >> 32)); 768 + pci_write_config_dword(filter_pdev, reg2->reg, 769 + (u32)reg2->config); 770 + pci_write_config_dword(filter_pdev, reg2->reg + 4, 771 + (u32)(reg2->config >> 32)); 772 + } 773 + } 774 + 775 + pci_write_config_dword(pdev, hwc->config_base, hwc->config | SNBEP_PMON_CTL_EN); 776 + } 777 + 778 + static struct intel_uncore_ops snbep_uncore_qpi_ops = { 779 + SNBEP_UNCORE_PCI_OPS_COMMON_INIT(), 780 + .enable_event = snbep_qpi_enable_event, 781 + .hw_config = snbep_qpi_hw_config, 782 + .get_constraint = uncore_get_constraint, 783 + .put_constraint = uncore_put_constraint, 784 + }; 785 + 770 786 #define SNBEP_UNCORE_PCI_COMMON_INIT() \ 771 787 .perf_ctr = SNBEP_PCI_PMON_CTR0, \ 772 788 .event_ctl = SNBEP_PCI_PMON_CTL0, \ ··· 851 757 }; 852 758 853 759 static struct intel_uncore_type snbep_uncore_qpi = { 854 - .name = "qpi", 855 - .num_counters = 4, 856 - .num_boxes = 2, 857 - .perf_ctr_bits = 48, 858 - .perf_ctr = SNBEP_PCI_PMON_CTR0, 859 - .event_ctl = SNBEP_PCI_PMON_CTL0, 860 - .event_mask = SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK, 861 - .box_ctl = SNBEP_PCI_PMON_BOX_CTL, 862 - .ops = &snbep_uncore_pci_ops, 863 - .event_descs = snbep_uncore_qpi_events, 864 - .format_group = &snbep_uncore_qpi_format_group, 760 + .name = "qpi", 761 + .num_counters = 4, 762 + .num_boxes = 2, 763 + .perf_ctr_bits = 48, 764 + .perf_ctr = SNBEP_PCI_PMON_CTR0, 765 + .event_ctl = SNBEP_PCI_PMON_CTL0, 766 + .event_mask = SNBEP_QPI_PCI_PMON_RAW_EVENT_MASK, 767 + .box_ctl = SNBEP_PCI_PMON_BOX_CTL, 768 + .num_shared_regs = 1, 769 + .ops = &snbep_uncore_qpi_ops, 770 + .event_descs = snbep_uncore_qpi_events, 771 + .format_group = &snbep_uncore_qpi_format_group, 865 772 }; 866 773 867 774 ··· 941 846 { /* R3QPI Link 1 */ 942 847 PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_UNC_R3QPI1), 943 848 .driver_data = UNCORE_PCI_DEV_DATA(SNBEP_PCI_UNCORE_R3QPI, 1), 849 + }, 850 + { /* QPI Port 0 filter */ 851 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x3c86), 852 + .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 853 + SNBEP_PCI_QPI_PORT0_FILTER), 854 + }, 855 + { /* QPI Port 0 filter */ 856 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x3c96), 857 + .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, 858 + SNBEP_PCI_QPI_PORT1_FILTER), 944 859 }, 945 860 { /* end: all zeroes */ } 946 861 };
+1 -1
arch/x86/kernel/cpu/perf_event_intel_uncore.h
··· 16 16 #define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff) 17 17 #define UNCORE_PCI_DEV_IDX(data) (data & 0xff) 18 18 #define UNCORE_EXTRA_PCI_DEV 0xff 19 - #define UNCORE_EXTRA_PCI_DEV_MAX 0 19 + #define UNCORE_EXTRA_PCI_DEV_MAX 2 20 20 21 21 /* support up to 8 sockets */ 22 22 #define UNCORE_SOCKET_MAX 8