Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2882994pxv; Mon, 12 Jul 2021 04:20:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT1334yG+tB5fG1S3Y4TZW9ko1HgjAwh2+aDhofrOSpKkqbX1vbJl67z/tQxsXz563mdob X-Received: by 2002:a92:360b:: with SMTP id d11mr36205434ila.111.1626088826461; Mon, 12 Jul 2021 04:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626088826; cv=none; d=google.com; s=arc-20160816; b=LyWLP7m/lRO+ysNT8jqZ6P+8pZ2veQw0oMes4duSWNxvaPRLyxk8rB2jVnVtmE9k/h RIOZ1ZPD/QQBsiz8Q34nWXON7gTs2huidzOzbXM/QTKbKA2985wxX6N+mZ2BcKyWH+UP kQKXzlHUeegA6NqFlm/Ro0tSyXaX6a8+AF2g0Lfo1YxNiseRdO8mDuMU6RYRWD1DaQWO lTXzoQpC/CV6vNPk8l1ac6MrYbfFxTNMpMHtY+fe38oNrBqgebGfZDb8cJIVVD+QwZzb NrTnzo1I/xu1iciA4/wEjKm90IOZ3h0dn3eqq6VbzVrDuX6QKRS5UB6z5Sp61UUT3nZv ePKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=DFYLSQxVqtV1bKBpUGhM8S306jbAsL81TGLPrVWj4wE=; b=pZ74kK46W0VAw0BgwSjjFqkT6WYx/L7mNVWyHKnmlAAfxCcZnlE4NH5mHnbeG0Jf5W QBK3fDqzJkznO5wOTHPj/e0RRdMHHniv4FkV8cin8lqQeGxfeEIuaTIVFdTt0sBmQ5S9 WVmy563RcdtMTdqamOhbgxQdavCMgs0NDKgmt+TkPJlZsSjHklAQlxqS3gJkMgEfD25U Yd42UU6BJ/WM4se5Ukw4Pyc9Ae3T1gM65v9ljsAKE/y38M5tQcwNCmTeumfqGx7JGdLJ lrBfZmBEIWt8uJJqlRiRH/wfKVEtOvCnBD3ZX9dyiT3btdFphKj3E9wWG4zHsiJUI++l Qcug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si15306160ioq.34.2021.07.12.04.20.15; Mon, 12 Jul 2021 04:20:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236150AbhGLLVx (ORCPT + 99 others); Mon, 12 Jul 2021 07:21:53 -0400 Received: from foss.arm.com ([217.140.110.172]:53758 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238594AbhGLLT4 (ORCPT ); Mon, 12 Jul 2021 07:19:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 90A336D; Mon, 12 Jul 2021 04:17:07 -0700 (PDT) Received: from [10.57.35.32] (unknown [10.57.35.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DFE53F694; Mon, 12 Jul 2021 04:17:06 -0700 (PDT) Subject: Re: [PATCH v2] coresight: tmc-etr: Speed up for bounce buffer in flat mode To: Leo Yan Cc: Mathieu Poirier , Mike Leach , Alexander Shishkin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20210710070115.462674-1-leo.yan@linaro.org> <20210712110916.GB704210@leoy-ThinkPad-X240s> From: Suzuki K Poulose Message-ID: <5f3148bf-3efa-5866-b426-8bab4eb40282@arm.com> Date: Mon, 12 Jul 2021 12:17:04 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210712110916.GB704210@leoy-ThinkPad-X240s> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/07/2021 12:09, Leo Yan wrote: > Hi Suzuki, > > On Mon, Jul 12, 2021 at 10:55:32AM +0100, Suzuki Kuruppassery Poulose wrote: > > [...] > >>> static void tmc_etr_sync_flat_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) >>> { >>> + struct etr_flat_buf *flat_buf = etr_buf->private; >>> + struct device *real_dev = flat_buf->dev->parent; >>> + >>> /* >>> * Adjust the buffer to point to the beginning of the trace data >>> * and update the available trace data. >>> @@ -648,6 +668,28 @@ static void tmc_etr_sync_flat_buf(struct etr_buf *etr_buf, u64 rrp, u64 rwp) >>> etr_buf->len = etr_buf->size; >>> else >>> etr_buf->len = rwp - rrp; >>> + >>> + if (etr_buf->offset + etr_buf->len > etr_buf->size) { >>> + int len1, len2; >>> + >>> + /* >>> + * If trace data is wrapped around, sync AUX bounce buffer >>> + * for two chunks: "len1" is for the trace date length at >>> + * the tail of bounce buffer, and "len2" is the length from >>> + * the start of the buffer after wrapping around. >>> + */ >>> + len1 = etr_buf->size - etr_buf->offset; >>> + len2 = etr_buf->len - len1; >>> + dma_sync_single_for_cpu(real_dev, >>> + flat_buf->daddr + etr_buf->offset, >>> + len1, DMA_FROM_DEVICE); >>> + dma_sync_single_for_cpu(real_dev, flat_buf->daddr, >>> + len2, DMA_FROM_DEVICE); >> >> We always start tracing at the beginning of the buffer and the only reason >> why we would get a wrap around, is when the buffer is full. >> So you could as well sync the entire buffer in one go >> >> dma_sync_single_for_cpu(real_dev, flat_buf->daddr, >> etr_buf->len, DMA_FROM_DEVICE); > > I am doubt why you conclude "always start tracing at the beginning of > the buffer"? I read the driver but cannot find any code in the driver > to reset rrp and rwp after fetching the trace data, or there have any > implict operation to reset pointers? The ETR is always programmed with the base address of the "ETR" buffer, which is *not the same* as the perf ring buffer, since we always do double buffering. We do not program the RRP/RWP of the ETR (except for the SoC-600, where it is mandatory and we set them to the base address). Thus there is no context associated with the ETR buffer. But at the end of the run, we do read the RRP/ RWP to figure out where the ETR has reached. As for reseting the RRP / RWP, at the beginning of a session, is done implicitly for the ETR (except for SoC-600 ETRs as explained above) by the hardware to the base address. Suzuki