drivers: firmware: pmu_vendor: add cmd to enable tracing

Update pmu_vendor protocol to include a command to enable
tracing on cpucp to improve debugging.

Change-Id: I1210df14bd98a22f8fde74f27fb88b577b5c1f8b
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
This commit is contained in:
Amir Vajid 2021-10-07 12:21:05 -07:00 committed by Gerrit - the friendly Code Review server
parent 9f64847f79
commit 199eef76ac
3 changed files with 67 additions and 4 deletions

View File

@ -6,7 +6,10 @@
#include "common.h"
#include <linux/scmi_pmu.h>
#define SET_PMU_MAP 11
enum scmi_c1dcvs_protocol_cmd {
SET_PMU_MAP = 11,
SET_ENABLE_TRACE,
};
struct pmu_map_msg {
uint8_t hw_cntrs[MAX_NUM_CPUS][MAX_CPUCP_EVT];
@ -36,13 +39,39 @@ static int scmi_send_pmu_map(const struct scmi_protocol_handle *ph,
return ret;
}
static int scmi_send_tunable_pmu(const struct scmi_protocol_handle *ph,
void *buf, u32 msg_id)
{
int ret;
struct scmi_xfer *t;
unsigned int *msg;
unsigned int *src = buf;
ret = ph->xops->xfer_get_init(ph, msg_id, sizeof(*msg), sizeof(*msg),
&t);
if (ret)
return ret;
msg = t->tx.buf;
*msg = cpu_to_le32(*src);
ret = ph->xops->do_xfer(ph, t);
ph->xops->xfer_put(ph, t);
return ret;
}
static int scmi_pmu_map(const struct scmi_protocol_handle *ph, void *buf)
{
return scmi_send_pmu_map(ph, buf, SET_PMU_MAP);
}
static int scmi_set_enable_trace(const struct scmi_protocol_handle *ph, void *buf)
{
return scmi_send_tunable_pmu(ph, buf, SET_ENABLE_TRACE);
}
static struct scmi_pmu_vendor_ops pmu_config_ops = {
.set_pmu_map = scmi_pmu_map,
.set_pmu_map = scmi_pmu_map,
.set_enable_trace = scmi_set_enable_trace,
};
static int scmi_pmu_protocol_init(const struct scmi_protocol_handle *ph)

View File

@ -75,6 +75,8 @@ static DEFINE_SPINLOCK(idle_list_lock);
static struct cpucp_hlos_map cpucp_map[MAX_CPUCP_EVT];
static struct kobject pmu_kobj;
static bool pmu_counters_enabled = true;
static unsigned int pmu_enable_trace;
/*
* is_amu_valid: Check if AMUs are supported and if the id corresponds to the
* four supported AMU counters i.e. SYS_AMEVCNTR0_CONST_EL0,
@ -957,7 +959,7 @@ struct qcom_pmu_attr {
#define to_pmu_attr(_attr) \
container_of(_attr, struct qcom_pmu_attr, attr)
#define PERF_ATTR_RW(_name) \
#define PMU_ATTR_RW(_name) \
static struct qcom_pmu_attr _name = \
__ATTR(_name, 0644, show_##_name, store_##_name)\
@ -981,9 +983,40 @@ static ssize_t store_enable_counters(struct kobject *kobj,
return count;
}
PERF_ATTR_RW(enable_counters);
static ssize_t show_enable_trace(struct kobject *kobj,
struct attribute *attr, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%u\n", pmu_enable_trace);
}
static ssize_t store_enable_trace(struct kobject *kobj,
struct attribute *attr, const char *buf,
size_t count)
{
unsigned int var;
int ret;
if (!ops)
return -ENODEV;
ret = kstrtouint(buf, 10, &var);
if (ret < 0)
return ret;
ret = ops->set_enable_trace(ph, &var);
if (ret < 0)
return ret;
pmu_enable_trace = var;
return count;
}
PMU_ATTR_RW(enable_counters);
PMU_ATTR_RW(enable_trace);
static struct attribute *pmu_settings_attr[] = {
&enable_counters.attr,
&enable_trace.attr,
NULL,
};

View File

@ -38,5 +38,6 @@ struct scmi_protocol_handle;
*/
struct scmi_pmu_vendor_ops {
int (*set_pmu_map)(const struct scmi_protocol_handle *ph, void *buf);
int (*set_enable_trace)(const struct scmi_protocol_handle *ph, void *buf);
};
#endif