From: Mathieu Poirier Date: Tue, 3 May 2016 17:34:01 +0000 (-0600) Subject: coresight: etb10: adjust read pointer only when needed X-Git-Tag: firefly_0821_release~176^2~4^2~44^2 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=4a192f60855a84820d361ec58eda0d043faab6f6;p=firefly-linux-kernel-4.4.55.git coresight: etb10: adjust read pointer only when needed The read pointer (read_ptr) needs to be adjusted only if its value has gone beyond the length of the memory buffer. Reported-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman (cherry picked from commit bedffda8cad46bedb6880bb98c23c51c715216c3) --- diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 92f942321e1e..4d20b0be0c0b 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -428,7 +428,8 @@ static void etb_update_buffer(struct coresight_device *csdev, read_ptr = (write_ptr + drvdata->buffer_depth) - to_read / ETB_FRAME_SIZE_WORDS; /* Wrap around if need be*/ - read_ptr &= ~(drvdata->buffer_depth - 1); + if (read_ptr > (drvdata->buffer_depth - 1)) + read_ptr -= drvdata->buffer_depth; /* let the decoder know we've skipped ahead */ local_inc(&buf->lost); }