From 619e3f8d8c2c9a88ec48706524747d1ba1614655 Mon Sep 17 00:00:00 2001
From: Luming Yu <luming.yu@intel.com>
Date: Fri, 29 Sep 2017 22:09:35 +0800
Subject: [PATCH v1 6/9] early pt: enable mtc freq packet

enable mtc freq packet

Signed-off-by: Luming Yu <luming.yu@intel.com>
---
 arch/x86/events/intel/early_pt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/events/intel/early_pt.c b/arch/x86/events/intel/early_pt.c
index 5335458..01570d2 100644
--- a/arch/x86/events/intel/early_pt.c
+++ b/arch/x86/events/intel/early_pt.c
@@ -56,6 +56,8 @@ static unsigned cyc_thresh_mask = 0;
 static unsigned mtc_freq_mask = 0;
 static unsigned addr_range_num = 0;
 
+static int mtc_freq = 0;
+
 static unsigned long pt_addr0_start = 0, pt_addr0_end = 0;
 static unsigned long pt_addr1_start = 0, pt_addr1_end = 0;
 
@@ -197,6 +199,9 @@ static int start_early_pt(void *arg)
 		}
 	}
 
+	if (mtc_freq && ((1U << (mtc_freq - 1)) & mtc_freq_mask))
+		val |= ((mtc_freq - 1) << 14) | MTC_EN;
+
 	if (wrmsrl_safe(MSR_IA32_RTIT_CTL, val) < 0) {
 		pr_info("early_pt start failed on cpu[%d]\n", cpu);
 		__this_cpu_write(early_pt_running, false);
@@ -401,3 +406,10 @@ static int __init early_pt_addr1_end_setup(char *arg)
 	return 0;
 }
 early_param("early_pt_addr1_end", early_pt_addr1_end_setup);
+
+static int __init early_pt_mtc_freq_setup(char *arg)
+{
+	sscanf(arg, "%d", &mtc_freq);
+	return 0;
+}
+early_param("mtc_freq", early_pt_mtc_freq_setup);
-- 
2.7.5

