Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754492AbdDKJMD (ORCPT ); Tue, 11 Apr 2017 05:12:03 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:36457 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754288AbdDKJKu (ORCPT ); Tue, 11 Apr 2017 05:10:50 -0400 From: Leo Yan To: Mathieu Poirier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Leo Yan , Mike Leach , Suzuki K Poulose Subject: [PATCH RFC 2/4] coresight: tmc: set read pointer before dump RAM Date: Tue, 11 Apr 2017 17:10:27 +0800 Message-Id: <1491901829-18477-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491901829-18477-1-git-send-email-leo.yan@linaro.org> References: <1491901829-18477-1-git-send-email-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1621 Lines: 48 When dump RAM, we need set read pointer so can make sure every time read the consistent content. If the RAM is full by checking status register (STS), so set the read pointer to same value with write pointer, otherwise set read point to 0 so can read from the start of RAM. Cc: Mathieu Poirier Cc: Mike Leach Cc: Suzuki K Poulose Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 6150dac..43cfeaa 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -43,10 +43,28 @@ static void tmc_etb_enable_hw(struct tmc_drvdata *drvdata) static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) { + u32 write_ptr, status; char *bufp; u32 read_data; int i; + write_ptr = readl_relaxed(drvdata->base + TMC_RWP); + + /* + * Get a hold of the status register and see if a wrap around + * has occurred. If so adjust things accordingly. + */ + status = readl_relaxed(drvdata->base + TMC_STS); + if (status & TMC_STS_FULL) + /* Tell the HW the reading start point */ + writel_relaxed(write_ptr, drvdata->base + TMC_RRP); + else + /* + * In case this is not first time to read ETB RAM, + * always write 0 for reading pointer. + */ + writel_relaxed(0x0, drvdata->base + TMC_RRP); + bufp = drvdata->buf; drvdata->len = 0; while (1) { -- 2.7.4