mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
coresight-etm4x: Controls pertaining to the counter functions
Adding sysfs entries related to the counter functionality, more specifically to set, control and reload the counters. Signed-off-by: Pratik Patel <[email protected]> Signed-off-by: Mathieu Poirier <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
5e5ff34406
commit
add2d5d0d1
2 changed files with 170 additions and 0 deletions
|
|
@ -1567,6 +1567,146 @@ static ssize_t seq_reset_event_store(struct device *dev,
|
|||
}
|
||||
static DEVICE_ATTR_RW(seq_reset_event);
|
||||
|
||||
static ssize_t cntr_idx_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
val = drvdata->cntr_idx;
|
||||
return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
|
||||
}
|
||||
|
||||
static ssize_t cntr_idx_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
if (kstrtoul(buf, 16, &val))
|
||||
return -EINVAL;
|
||||
if (val >= drvdata->nr_cntr)
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* Use spinlock to ensure index doesn't change while it gets
|
||||
* dereferenced multiple times within a spinlock block elsewhere.
|
||||
*/
|
||||
spin_lock(&drvdata->spinlock);
|
||||
drvdata->cntr_idx = val;
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return size;
|
||||
}
|
||||
static DEVICE_ATTR_RW(cntr_idx);
|
||||
|
||||
static ssize_t cntrldvr_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
val = drvdata->cntrldvr[idx];
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
|
||||
}
|
||||
|
||||
static ssize_t cntrldvr_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
if (kstrtoul(buf, 16, &val))
|
||||
return -EINVAL;
|
||||
if (val > ETM_CNTR_MAX_VAL)
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
drvdata->cntrldvr[idx] = val;
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return size;
|
||||
}
|
||||
static DEVICE_ATTR_RW(cntrldvr);
|
||||
|
||||
static ssize_t cntr_val_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
val = drvdata->cntr_val[idx];
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
|
||||
}
|
||||
|
||||
static ssize_t cntr_val_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
if (kstrtoul(buf, 16, &val))
|
||||
return -EINVAL;
|
||||
if (val > ETM_CNTR_MAX_VAL)
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
drvdata->cntr_val[idx] = val;
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return size;
|
||||
}
|
||||
static DEVICE_ATTR_RW(cntr_val);
|
||||
|
||||
static ssize_t cntr_ctrl_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
val = drvdata->cntr_ctrl[idx];
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return scnprintf(buf, PAGE_SIZE, "%#lx\n", val);
|
||||
}
|
||||
|
||||
static ssize_t cntr_ctrl_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t size)
|
||||
{
|
||||
u8 idx;
|
||||
unsigned long val;
|
||||
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
|
||||
|
||||
if (kstrtoul(buf, 16, &val))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&drvdata->spinlock);
|
||||
idx = drvdata->cntr_idx;
|
||||
drvdata->cntr_ctrl[idx] = val;
|
||||
spin_unlock(&drvdata->spinlock);
|
||||
return size;
|
||||
}
|
||||
static DEVICE_ATTR_RW(cntr_ctrl);
|
||||
|
||||
static ssize_t cpu_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
|
|
@ -1613,6 +1753,10 @@ static struct attribute *coresight_etmv4_attrs[] = {
|
|||
&dev_attr_seq_state.attr,
|
||||
&dev_attr_seq_event.attr,
|
||||
&dev_attr_seq_reset_event.attr,
|
||||
&dev_attr_cntr_idx.attr,
|
||||
&dev_attr_cntrldvr.attr,
|
||||
&dev_attr_cntr_val.attr,
|
||||
&dev_attr_cntr_ctrl.attr,
|
||||
&dev_attr_cpu.attr,
|
||||
NULL,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue