At every time the driver begins to write ring buffer, it will update the page index 'buf->cur' and offset value 'buf->offset'; but after update the ring buffer these two values will not be set. So these two values are mainly indicated the start point to fill ring buffer, but we have no chance to know where is the last writing point. This results in the post-mortem analysis tool (e.g. crash extension program) to read incomplete trace data from the dump.
This patch is to update CoreSight private structure to track the latest buffer state in 'buf->cur' and 'buf->offset', at the end this can delivery correct info of ring buffer for offline tool.
Signed-off-by: Leo Yan leo.yan@linaro.org --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 6265370..4ea1cd5 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -487,6 +487,14 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, to_read = to_read + barrier_sz; }
+ /* + * Though tmc_set_etf_buffer() will update the page index and offset + * for next data transferring, here update them to serve kernel panic + * emergency thus kdump can know the buffer last writing point. + */ + buf->cur = cur; + buf->offset = offset; + CS_LOCK(drvdata->base);
return to_read;