From patchwork Wed Apr 27 18:24:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 66820 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2342436qge; Wed, 27 Apr 2016 11:24:46 -0700 (PDT) X-Received: by 10.98.102.20 with SMTP id a20mr14013640pfc.137.1461781486060; Wed, 27 Apr 2016 11:24:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xm8si10912041pab.11.2016.04.27.11.24.45; Wed, 27 Apr 2016 11:24:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752910AbcD0SYn (ORCPT + 29 others); Wed, 27 Apr 2016 14:24:43 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:33598 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752717AbcD0SYm (ORCPT ); Wed, 27 Apr 2016 14:24:42 -0400 Received: by mail-io0-f172.google.com with SMTP id f89so54713212ioi.0 for ; Wed, 27 Apr 2016 11:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=M0Vz4jELsdygRwR1zfT65DzxX2fCuAAmE/u/zXWmzz4=; b=WkgnVd6WyF9asY7T2Th/eFqZmggnOPQa8wTWh3XjHaWxgXOkP9JE4WYAAGa8kUXbli RSdDtPV/DKJLyTmBTH8x8a8FvUJWe3+Itsr1f174sXJdA9beI9ZEcQZag0JPxJC9NSEM o2qdVSMCFw3+fcI7VdcdkUOgF5nEzF83VgcuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=M0Vz4jELsdygRwR1zfT65DzxX2fCuAAmE/u/zXWmzz4=; b=C/Dqa5vl5CVvB+QJ0CgQCr/q4aOVGbX2SVc28uc3D4ioXGPtrM9Rj40TzRNZzIYoVO F8mbsuOFO9fOuPc34FFrQEbGB587ckLP6zt1bZV3b2GF1J+rPz320fYjel0mbETyCMhX JDYtOXHGJdbkVynFPz4QFaSC52+nDkrhjvd++YIVK0MliejEYGE5IFsP89jlTR9sdOSw CuJk97M3f/ZeGoDmUMg50cQt57vEpSrW5mPio5OyKovOgt+qCehSwA8TN0sAYStNhwNk pTpXcT2hDWS72NJQAPAjOuyW/2e2FDhHOsJY4IQ8mGRf8Ht5SteXjcD/Se5goGOfrFJN dTbw== X-Gm-Message-State: AOPr4FWq9G0qxv+oW9PAdTgqlD3RUbabh/y4YSebOykAYJstE/X0MRaXTh29h7fgbpVJlGKQ X-Received: by 10.107.142.194 with SMTP id q185mr11960812iod.37.1461781481358; Wed, 27 Apr 2016 11:24:41 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id ym16sm15162067igc.4.2016.04.27.11.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Apr 2016 11:24:39 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org, Suzuki.Poulose@arm.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] coresight: etb10: adjust read pointer only when needed Date: Wed, 27 Apr 2016 12:24:38 -0600 Message-Id: <1461781478-6226-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/hwtracing/coresight/coresight-etb10.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 586c98fbdb03..1e4031ee8969 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); }