Commit a440617e authored by Chunyan Zhang's avatar Chunyan Zhang Committed by Greg Kroah-Hartman

coresight-etm3x: Support context-ID tracing when PID namespace is enabled

The Coresight ETM drivers already support context-ID tracing, but it won't
work when PID namespace is enabled. This is because when using PID
namespace a process id (ie. VPID) seen from the current namespace differs
from the id (ie. PID) seen by kernel.

So when users write the process id seen by themselves to ETM, there needs
to be a translation from VPID to PID, as such ETM drivers will write the
PID into the Context ID register correctly.
Signed-off-by: default avatarChunyan Zhang <zhang.chunyan@linaro.org>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 72210227
...@@ -184,6 +184,8 @@ ...@@ -184,6 +184,8 @@
* @seq_curr_state: current value of the sequencer register. * @seq_curr_state: current value of the sequencer register.
* @ctxid_idx: index for the context ID registers. * @ctxid_idx: index for the context ID registers.
* @ctxid_pid: value for the context ID to trigger on. * @ctxid_pid: value for the context ID to trigger on.
* @ctxid_vpid: Virtual PID seen by users if PID namespace is enabled, otherwise
* the same value of ctxid_pid.
* @ctxid_mask: mask applicable to all the context IDs. * @ctxid_mask: mask applicable to all the context IDs.
* @sync_freq: Synchronisation frequency. * @sync_freq: Synchronisation frequency.
* @timestamp_event: Defines an event that requests the insertion * @timestamp_event: Defines an event that requests the insertion
...@@ -236,6 +238,7 @@ struct etm_drvdata { ...@@ -236,6 +238,7 @@ struct etm_drvdata {
u32 seq_curr_state; u32 seq_curr_state;
u8 ctxid_idx; u8 ctxid_idx;
u32 ctxid_pid[ETM_MAX_CTXID_CMP]; u32 ctxid_pid[ETM_MAX_CTXID_CMP];
u32 ctxid_vpid[ETM_MAX_CTXID_CMP];
u32 ctxid_mask; u32 ctxid_mask;
u32 sync_freq; u32 sync_freq;
u32 timestamp_event; u32 timestamp_event;
......
...@@ -237,8 +237,11 @@ static void etm_set_default(struct etm_drvdata *drvdata) ...@@ -237,8 +237,11 @@ static void etm_set_default(struct etm_drvdata *drvdata)
drvdata->seq_curr_state = 0x0; drvdata->seq_curr_state = 0x0;
drvdata->ctxid_idx = 0x0; drvdata->ctxid_idx = 0x0;
for (i = 0; i < drvdata->nr_ctxid_cmp; i++) for (i = 0; i < drvdata->nr_ctxid_cmp; i++) {
drvdata->ctxid_pid[i] = 0x0; drvdata->ctxid_pid[i] = 0x0;
drvdata->ctxid_vpid[i] = 0x0;
}
drvdata->ctxid_mask = 0x0; drvdata->ctxid_mask = 0x0;
} }
...@@ -1393,7 +1396,7 @@ static ssize_t ctxid_pid_show(struct device *dev, ...@@ -1393,7 +1396,7 @@ static ssize_t ctxid_pid_show(struct device *dev,
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
val = drvdata->ctxid_pid[drvdata->ctxid_idx]; val = drvdata->ctxid_vpid[drvdata->ctxid_idx];
spin_unlock(&drvdata->spinlock); spin_unlock(&drvdata->spinlock);
return sprintf(buf, "%#lx\n", val); return sprintf(buf, "%#lx\n", val);
...@@ -1404,15 +1407,18 @@ static ssize_t ctxid_pid_store(struct device *dev, ...@@ -1404,15 +1407,18 @@ static ssize_t ctxid_pid_store(struct device *dev,
const char *buf, size_t size) const char *buf, size_t size)
{ {
int ret; int ret;
unsigned long val; unsigned long vpid, pid;
struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent);
ret = kstrtoul(buf, 16, &val); ret = kstrtoul(buf, 16, &vpid);
if (ret) if (ret)
return ret; return ret;
pid = coresight_vpid_to_pid(vpid);
spin_lock(&drvdata->spinlock); spin_lock(&drvdata->spinlock);
drvdata->ctxid_pid[drvdata->ctxid_idx] = val; drvdata->ctxid_pid[drvdata->ctxid_idx] = pid;
drvdata->ctxid_vpid[drvdata->ctxid_idx] = vpid;
spin_unlock(&drvdata->spinlock); spin_unlock(&drvdata->spinlock);
return size; return size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment