coresight: etm4x: implementing user/kernel mode tracing
authorMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 5 Apr 2016 17:53:48 +0000 (11:53 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 1 May 2016 21:12:14 +0000 (14:12 -0700)
Adding new mode to limit tracing to kernel or user space.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
drivers/hwtracing/coresight/coresight-etm4x.c
drivers/hwtracing/coresight/coresight-etm4x.h

index a996db7ef2fcf97911cf31200181b47fa03ccc5a..0e80ec6684022f265e88f11b0e33fd6d84660d09 100644 (file)
@@ -440,6 +440,9 @@ static ssize_t mode_store(struct device *dev,
        else
                config->vinst_ctrl &= ~BIT(11);
 
+       if (config->mode & (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
+               etm4_config_trace_mode(config);
+
        spin_unlock(&drvdata->spinlock);
 
        return size;
index 9f51a8f47650eeab569fa98838a95c1c7310893f..88b8bc0f6549a1dbb0d9596ad597a4bffbccfec3 100644 (file)
@@ -566,6 +566,41 @@ static void etm4_set_default(struct etmv4_config *config)
        config->vissctlr = 0x0;
 }
 
+void etm4_config_trace_mode(struct etmv4_config *config)
+{
+       u32 addr_acc, mode;
+
+       mode = config->mode;
+       mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER);
+
+       /* excluding kernel AND user space doesn't make sense */
+       WARN_ON_ONCE(mode == (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER));
+
+       /* nothing to do if neither flags are set */
+       if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
+               return;
+
+       addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP];
+       /* clear default config */
+       addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS);
+
+       /*
+        * EXLEVEL_NS, bits[15:12]
+        * The Exception levels are:
+        *   Bit[12] Exception level 0 - Application
+        *   Bit[13] Exception level 1 - OS
+        *   Bit[14] Exception level 2 - Hypervisor
+        *   Bit[15] Never implemented
+        */
+       if (mode & ETM_MODE_EXCL_KERN)
+               addr_acc |= ETM_EXLEVEL_NS_OS;
+       else
+               addr_acc |= ETM_EXLEVEL_NS_APP;
+
+       config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc;
+       config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc;
+}
+
 static int etm4_cpu_callback(struct notifier_block *nfb, unsigned long action,
                            void *hcpu)
 {
index f7748ae634510932124faded9e22975c3faa9b3d..a291d4cc8bd840f658896fca249a798a1193d3ec 100644 (file)
 #define ETM_MODE_TRACE_RESET           BIT(25)
 #define ETM_MODE_TRACE_ERR             BIT(26)
 #define ETM_MODE_VIEWINST_STARTSTOP    BIT(27)
-#define ETMv4_MODE_ALL                 0xFFFFFFF
+#define ETMv4_MODE_ALL                 (GENMASK(27, 0) | \
+                                        ETM_MODE_EXCL_KERN | \
+                                        ETM_MODE_EXCL_USER)
 
 #define TRCSTATR_IDLE_BIT              0
 #define ETM_DEFAULT_ADDR_COMP          0
@@ -414,4 +416,5 @@ enum etm_addr_type {
 };
 
 extern const struct attribute_group *coresight_etmv4_groups[];
+void etm4_config_trace_mode(struct etmv4_config *config);
 #endif