#include <linux/uaccess.h>
#include <linux/clk.h>
#include <linux/perf_event.h>
+#include <linux/perf/arm_pmu.h>
#include <asm/sections.h>
#include "coresight-etm.h"
if (attr->config & ~ETM3X_SUPPORTED_OPTIONS)
return -EINVAL;
- config->ctrl = attr->config;
+ config->ctrl = 0;
- /* Don't trace contextID when runs in non-root PID namespace */
- if (!task_is_in_init_pid_ns(current))
- config->ctrl &= ~ETMCR_CTXID_SIZE;
+ if (ATTR_CFG_GET_FLD(attr, cycacc))
+ config->ctrl |= ETMCR_CYC_ACC;
+
+ if (ATTR_CFG_GET_FLD(attr, timestamp))
+ config->ctrl |= ETMCR_TIMESTAMP_EN;
/*
- * Possible to have cores with PTM (supports ret stack) and ETM
- * (never has ret stack) on the same SoC. So if we have a request
- * for return stack that can't be honoured on this core then
- * clear the bit - trace will still continue normally
+ * Possible to have cores with PTM (supports ret stack) and ETM (never
+ * has ret stack) on the same SoC. So only enable when it can be honored
+ * - trace will still continue normally otherwise.
*/
- if ((config->ctrl & ETMCR_RETURN_STACK) &&
- !(drvdata->etmccer & ETMCCER_RETSTACK))
- config->ctrl &= ~ETMCR_RETURN_STACK;
+ if (ATTR_CFG_GET_FLD(attr, retstack) &&
+ (drvdata->etmccer & ETMCCER_RETSTACK))
+ config->ctrl |= ETMCR_RETURN_STACK;
return 0;
}