coresight: etb10: adjust read pointer only when needed
authorMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 3 May 2016 17:34:01 +0000 (11:34 -0600)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 1 Jun 2016 21:46:44 +0000 (15:46 -0600)
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 <suzuki.poulose@arm.com>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit bedffda8cad46bedb6880bb98c23c51c715216c3)

drivers/hwtracing/coresight/coresight-etb10.c

index 92f942321e1e86f7f271d8c66d979a740e2f4577..4d20b0be0c0b6a337cdec7cbbfd17f8ce94e2a63 100644 (file)
@@ -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);
        }