Received: by 10.192.165.148 with SMTP id m20csp4710027imm; Tue, 1 May 2018 02:14:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqIqNjEj/C5xHq/0d4j04D8Qpw1QUOypYAagYfoGq+9bnYQIYYQxW3iGQIDu8tRDZcSQkaS X-Received: by 2002:a63:6e84:: with SMTP id j126-v6mr12610798pgc.310.1525166061025; Tue, 01 May 2018 02:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525166060; cv=none; d=google.com; s=arc-20160816; b=u7pc/h/LRUDOxVaeZ9lq39cbjknuEXFf5PIdsSylADRwFRVe+7T/oEbTCGcxdyMUqN BxhPilJw/M7CkYE4J/7zizGXoCKp5H4UFclwoXO94VOwrCyV7xZIUJC32IV97IiYxnOr RrB4NqagI85h1mif2rJS4WLHbqTX665fmIFOw8mJ+Ov1RvqiR9e5Su7gz2ZEzas0vCrc BGJ0UXtq513uwLIl0PnF/5TpN5kXH+iWDQiaawhF1Xnh/5ECgnBRdzX9OckVY3cbWXR2 bD+3llCoBkhJj7AYOvnTYyyH51+E725OhJN2PUVJ7vfsD1zlqIm3bv6zPQZxNMBZzlfK RLCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=z9rT+Puc9moe5yTnOqjs+W4/ZOzLaFmzzHS9lmhAhbI=; b=rQ3QDQCDFeOLTNO9wppwXz+KZUKHqjo4PifAg1kXA3XAXztIcePHurt50uJqA9Zx2S wTk/G5ZhTqCMPzr/jkGzVZfURkWtrKYNmJdBAzl3C5cH98C0mNvLBGHzeSyXUBbh7gpB 6ibsaLlqaUN8ufdiy+xsMnqRZUAjybdDnnG7fnSnoq8eSpGWjMV/IvI6K7gNdDIh16FX Pq7nAyLmoKGakZf1KYRDpjLxWoxkPPFMTnXkqLFybswuZb6gsc2Lpl8c9/+g2KDWCS2Y UjOwjsc838AFnzhSG/T9NAdLvvZ3w5hU/uPJHcS/hY9SlCFg8esLmC9vfvvg3j0tbm+k XYxg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w61-v6si9089994plb.155.2018.05.01.02.14.06; Tue, 01 May 2018 02:14:20 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755392AbeEAJNX (ORCPT + 99 others); Tue, 1 May 2018 05:13:23 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755068AbeEAJML (ORCPT ); Tue, 1 May 2018 05:12:11 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 352FC15BF; Tue, 1 May 2018 02:12:11 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.206.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 01B723F487; Tue, 1 May 2018 02:12:08 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.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, Suzuki K Poulose Subject: [PATCH v2 25/27] coresight: etr_buf: Add helper for padding an area of trace data Date: Tue, 1 May 2018 10:10:55 +0100 Message-Id: <1525165857-11096-26-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> References: <1525165857-11096-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } /* -- 2.7.4