Received: by 10.192.165.148 with SMTP id m20csp4578368imm; Tue, 8 May 2018 10:36:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpKtvxGSUVnG/SoRq7hZQSeYk7X+jim0KiaeSYIsiu5zkd7jqE1jCLJ9SYiJQlZL93Zj2up X-Received: by 10.98.19.6 with SMTP id b6mr40238034pfj.58.1525801008633; Tue, 08 May 2018 10:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525801008; cv=none; d=google.com; s=arc-20160816; b=zsWBQVqtvskfheGABUq2oMOsEH0Vcs0F4ZXytAlYDJC5V2snjIrCOfxXdP/wSb8a4i jW/AL8r8d4rXUu6lvGvNGMgHAOPQFiLwyjKTDA4gOk1DSPGD49qaMUVLEL3Z1uhapNdT fiZemNC4w8dCM0MQo5TyGZNdxPFglToOYldx9lJJpjpSIV819YGA1H+VTBcAPOD0HavK EQbGuYbysHbmMLe7mC44dwA+BMCNurae9UNVSgVSYJfUtF2+y1A8I55/JCpMbKRyaFdO 5HgYqAkyngfzidkV/uM1i0nI0fLZiOuMh6V8yzQg7U7dB3pKe8IjVkaNuKR1/56b/p/9 OFtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=SmAh2YCjTkwGzOzkFMJyA10XCTQdaH4QTSvXNMiplBY=; b=fQyyr7Kb3zQyurJjNEW6lQgQT0UDEjbN62xehQvPto4Rv1YG5ar9pkFUWSEmYjP1hL my9Sfbbuz1fVPGN7XG6+WpSLoDt0PsJ/tspF95+8gN9s5bTwqHB2Z4jmxiofW5UU1ps9 oyym36SxcMPDpgmwGN51im+xC5xI2bZbYx1itvyI/CIYBFyT4Mu8LrcLvW2rQ0HrNkVz LI5r3V+MPAbsDqmzLsei1rmrtrynOryE+OThqkf2vePSielye9kyxx9ICPNAGhgKqaMG 6qtKXwRTNOiQgB6RDCkRJIA2AuhuVNGiFe4CvEa1vu/IUFuYLKpUMtWZmjDJafBHXZga KISQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PFxQjVx2; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z21-v6si20506695pgn.570.2018.05.08.10.36.32; Tue, 08 May 2018 10:36:48 -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 header.s=google header.b=PFxQjVx2; 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 sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755512AbeEHRew (ORCPT + 99 others); Tue, 8 May 2018 13:34:52 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:44738 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754460AbeEHRev (ORCPT ); Tue, 8 May 2018 13:34:51 -0400 Received: by mail-pl0-f67.google.com with SMTP id e6-v6so2637207plt.11 for ; Tue, 08 May 2018 10:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SmAh2YCjTkwGzOzkFMJyA10XCTQdaH4QTSvXNMiplBY=; b=PFxQjVx2Gdc/yz8o91hhUw4YUbJ5RBsnEi+qk1EjmbZMEfxktWUZNMXFJiMDBB9GRT hDeHvFkGvi+L+QAD4rveP6RzpTgW/DTyRSW+ipAgOey7lmGJM0eWdX6eCfiHiRyMZlEJ PHR8SNDaqnl77WsI7Vyo2yVswALYvokKmcVvg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SmAh2YCjTkwGzOzkFMJyA10XCTQdaH4QTSvXNMiplBY=; b=Gn5JvRZXoALc+kzw+6cPiRQX+IXnuiNxK06hewO+U7QsuJC/PYa08k4gWeutFl+lPm LRtUdkiRjHbHBR5+L7ptm8NDUTs2vdXV/OIxLAYS2r8bxFibwcS9b4mYalsaOGJqGWdh wAwm70DiMMnjKIVefbHyjNES0bMy3Rb2Mcs+t1GD2hwVjef7dDJBN+GPwv2XyeWGzjcw HRtoc5snzWL0YEFIGCB3QJ7p3i1WReY2sMrJrRDH1maT/UxivhL3o0tpVLZ8MouLXb1U 0r2XJ/SmjH6qua/q80BjzQQscVGuayxkDPkDeXpYfng2UBIC5IG86MAocnclrrNFM5Pi EiTw== X-Gm-Message-State: ALQs6tApmjkHUN82yCcwdHH+CbcC4ILq+10r5rYKbz/vhD0e9z8lt6bD 36nYXGD+wJZ9TMKw/UJfkRzRjA== X-Received: by 2002:a17:902:7008:: with SMTP id y8-v6mr18218944plk.141.1525800890517; Tue, 08 May 2018 10:34:50 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c10-v6sm30935259pgn.38.2018.05.08.10.34.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 10:34:49 -0700 (PDT) Date: Tue, 8 May 2018 11:34:47 -0600 From: Mathieu Poirier To: Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mike.leach@linaro.org, robert.walker@arm.com, mark.rutland@arm.com, will.deacon@arm.com, robin.murphy@arm.com, sudeep.holla@arm.com, frowand.list@gmail.com, robh@kernel.org, john.horley@arm.com Subject: Re: [PATCH v2 25/27] coresight: etr_buf: Add helper for padding an area of trace data Message-ID: <20180508173447.GB3389@xps15> References: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> <1525165857-11096-26-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525165857-11096-26-git-send-email-suzuki.poulose@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 01, 2018 at 10:10:55AM +0100, Suzuki K Poulose wrote: > This patch adds a helper to insert barrier packets for a given > size (aligned to packet size) at given offset in an etr_buf. This > will be used later for perf mode when we try to start in the > middle of an SG buffer. > > Cc: Mathieu Poirier > Signed-off-by: Suzuki K Poulose > --- > drivers/hwtracing/coresight/coresight-tmc-etr.c | 53 ++++++++++++++++++++++--- > 1 file changed, 47 insertions(+), 6 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index 7551272..8159e84 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -1083,18 +1083,59 @@ static ssize_t tmc_etr_buf_get_data(struct etr_buf *etr_buf, > return etr_buf->ops->get_data(etr_buf, (u64)offset, len, bufpp); > } > > +/* > + * tmc_etr_buf_insert_barrier_packets : Insert barrier packets at @offset upto > + * @size of bytes in the given buffer. @size should be aligned to the barrier > + * packet size. > + * > + * Returns the new @offset after filling the barriers on success. Otherwise > + * returns error. > + */ > static inline s64 > -tmc_etr_buf_insert_barrier_packet(struct etr_buf *etr_buf, u64 offset) > +tmc_etr_buf_insert_barrier_packets(struct etr_buf *etr_buf, > + u64 offset, u64 size) > { > ssize_t len; > char *bufp; > > - len = tmc_etr_buf_get_data(etr_buf, offset, > - CORESIGHT_BARRIER_PKT_SIZE, &bufp); > - if (WARN_ON(len <= CORESIGHT_BARRIER_PKT_SIZE)) > + if (size < CORESIGHT_BARRIER_PKT_SIZE) > return -EINVAL; > - coresight_insert_barrier_packet(bufp); > - return offset + CORESIGHT_BARRIER_PKT_SIZE; > + /* > + * Normally the size should be aligned to the frame size > + * of the ETR. Even if it isn't, the decoder looks for a > + * barrier packet at a frame size aligned offset. So align > + * the buffer to frame size first and then fill barrier > + * packets. > + */ > + do { > + len = tmc_etr_buf_get_data(etr_buf, offset, size, &bufp); > + if (WARN_ON(len <= 0)) > + return -EINVAL; > + /* > + * We are guaranteed that @bufp will point to a linear range > + * of @len bytes, where @len <= @size. > + */ > + size -= len; > + offset += len; > + while (len >= CORESIGHT_BARRIER_PKT_SIZE) { > + coresight_insert_barrier_packet(bufp); > + bufp += CORESIGHT_BARRIER_PKT_SIZE; > + len -= CORESIGHT_BARRIER_PKT_SIZE; > + } > + > + /* If we reached the end of the buffer, wrap around */ > + if (offset == etr_buf->size) > + offset -= etr_buf->size; > + } while (size); > + > + return offset; > +} > + > +static inline s64 > +tmc_etr_buf_insert_barrier_packet(struct etr_buf *etr_buf, u64 offset) > +{ > + return tmc_etr_buf_insert_barrier_packets(etr_buf, offset, > + CORESIGHT_BARRIER_PKT_SIZE); Indentation > } > > /* > -- > 2.7.4 >