Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1141949ybl; Fri, 23 Aug 2019 14:05:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxvKxA0mFIdmB+22adf8hxhfqMTxhCFJkW0E7l+YnPUdrp9quS6OnZndZqVW/c2lIWtzPD X-Received: by 2002:a63:553:: with SMTP id 80mr4668907pgf.280.1566594314288; Fri, 23 Aug 2019 14:05:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566594314; cv=none; d=google.com; s=arc-20160816; b=EETrdiSnNWXgJ0LzRti+DauP3TYwyeom2uCibfGMoLAZr4yNXj7hKBdNPxwD2aUGKe LOInIMgVhL+0fjRv9BJnKIrmedjTbAU12d56ak9hZc/RIJ8G8nS+CxbJZHtnCo/z6zBl +gvn/Gd+d9UjDtlLJKcwRRPmx8Gdqzyxqm47lTPCD6LAMaBZ85V8tAkmCL/+O485Gl5F 5BC401sf6Qaoq0n8K0Z1o8T1bge00sFRC93I0USTtuItYr9a9J+V8QYPgrlrhuWQSZKS svVDrLqfVUZFeKlGl+KXyMIHos8bKCugQeHhrWiwHfbLhrW8gRv2w5L+XZQ/DzoqeJeh r34w== 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; bh=gqMJISdK1sCvYoXtpRx34/j2w5oB126SSByYfrdAv0A=; b=aFlTxEHWyDJGyuTbVdZzEllFj87xh4Vl3Mcet1RytZaGcJHX7xr9FKoOE08LAWSmHX M+CsbBX4rTdh67Vi3tA1HIkSDlQh67trY4uI1orcfT8XEz9So22EN5N8aUDPRR2y9NaI mEgeUo8UXxSBaOBB0+f+Cw/HY9wD8V/7uluToXG0U3h8y/tjSYxXNjvuwWQZ/m5CpHB0 LTVNcw2jhHao62VKqNp9wm7jagbYzF5blX6+wbaJL2lK+c77zUdqSfORf3564SoXiny2 ivcTfaUEdxBchqSH90a48paxfHAmltv30zsj1sG9hIow1ejIOh/yXdnF9LjYVF65+TL5 SIOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WA1nHmf0; 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 x3si3507662plv.422.2019.08.23.14.04.56; Fri, 23 Aug 2019 14:05:14 -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=WA1nHmf0; 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 S2388346AbfHWIWc (ORCPT + 99 others); Fri, 23 Aug 2019 04:22:32 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:40586 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729113AbfHWIWc (ORCPT ); Fri, 23 Aug 2019 04:22:32 -0400 Received: by mail-yw1-f65.google.com with SMTP id z64so3515271ywe.7 for ; Fri, 23 Aug 2019 01:22:31 -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=gqMJISdK1sCvYoXtpRx34/j2w5oB126SSByYfrdAv0A=; b=WA1nHmf0HPn+DPmdLUPjZRzKgLBGLIIYwMtxCzN3RoUYJpZE7Jv7ZuPEECCwMvslsz zE+c63vSSHU/W0CzZy8AC4VLrulnjBfjgACbqqopi3m53qj+YK0oSf+NqAlnk37HSXYs Uyi+4Rh4CPeHS8oJCy6LasuAHWsL15kxJIrZ++ysLepjEx/WJTXyudh2M3XnS4XNcPf4 6uFgLMupMLHUrVD4dibamjFoaT0vA556V/yrOaPK10AZoiSWRO1o2yJf2VWP1Nwma69A xae4VAM5Q/qAnAt/RhiPiHn3Hq+wQPX159xy1a2v+wOSfieuFg8dTwrJaa2j8cnN/Ipx 6ZHw== 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=gqMJISdK1sCvYoXtpRx34/j2w5oB126SSByYfrdAv0A=; b=MXRdDU3aR7t90bXDMcbldjGjIe07T2rIDM/h+fCo7vspCC2IkhfP15/oFOpojm+Fvf /cwR5s0EDNIWBYjB7F92iefP8xYqmASm3yO7hNz9lSxMfcXcaAxwKBmlXRWkXCRM5v81 wK/SZ5uA8vi2nC7GhdNeyNXnE4vMZ0nQPEdZ1zQIBX0YVSNDixdk3AlIsJqHnXxgTXPe RWo2mPR66wEvWGawdsz1zl8meNep8vwDLSXY3gNnEO4Q46ImKcorzghkuVb/3IfWuGEt 2LVtQS8b5CcxsJQFxF9r/wSPtA9pf4GLSMIOa/aETRKIciitSD6zMb56bJvUTMG6FuQ4 0ppQ== X-Gm-Message-State: APjAAAX+/v/ZScHtYwFjKybhq7vDaTNuFLQPRQosHcjLaxfJ/iavfchO RoAu2b7xOAX3QmETV6Uocwpr+Q== X-Received: by 2002:a0d:ddcd:: with SMTP id g196mr2330144ywe.460.1566548551310; Fri, 23 Aug 2019 01:22:31 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li1320-244.members.linode.com. [45.79.221.244]) by smtp.gmail.com with ESMTPSA id x67sm437667ywg.70.2019.08.23.01.22.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Aug 2019 01:22:27 -0700 (PDT) Date: Fri, 23 Aug 2019 16:22:21 +0800 From: Leo Yan To: Mathieu Poirier Cc: yabinc@google.com, suzuki.poulose@arm.com, mike.leach@arm.com, alexander.shishkin@linux.intel.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] coresight: tmc-etr: Add barrier packet when moving offset forward Message-ID: <20190823082221.GB18092@leoy-ThinkPad-X240s> References: <20190822220915.8876-1-mathieu.poirier@linaro.org> <20190822220915.8876-3-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190822220915.8876-3-mathieu.poirier@linaro.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mathieu, On Thu, Aug 22, 2019 at 04:09:15PM -0600, Mathieu Poirier wrote: > This patch adds barrier packets in the trace stream when the offset in the > data buffer needs to be moved forward. Otherwise the decoder isn't aware > of the break in the stream and can't synchronise itself with the trace > data. > > Signed-off-by: Mathieu Poirier > --- > .../hwtracing/coresight/coresight-tmc-etr.c | 43 ++++++++++++++----- > 1 file changed, 33 insertions(+), 10 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index 4f000a03152e..0e4cd6ec5f28 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -946,10 +946,6 @@ static void tmc_sync_etr_buf(struct tmc_drvdata *drvdata) > WARN_ON(!etr_buf->ops || !etr_buf->ops->sync); > > etr_buf->ops->sync(etr_buf, rrp, rwp); > - > - /* Insert barrier packets at the beginning, if there was an overflow */ > - if (etr_buf->full) > - tmc_etr_buf_insert_barrier_packet(etr_buf, etr_buf->offset); > } > > static void __tmc_etr_enable_hw(struct tmc_drvdata *drvdata) > @@ -1415,10 +1411,11 @@ static void tmc_free_etr_buffer(void *config) > * buffer to the perf ring buffer. > */ > static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, > + unsigned long src_offset, > unsigned long to_copy) > { > long bytes; > - long pg_idx, pg_offset, src_offset; > + long pg_idx, pg_offset; > unsigned long head = etr_perf->head; > char **dst_pages, *src_buf; > struct etr_buf *etr_buf = etr_perf->etr_buf; > @@ -1427,7 +1424,6 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, > pg_idx = head >> PAGE_SHIFT; > pg_offset = head & (PAGE_SIZE - 1); > dst_pages = (char **)etr_perf->pages; > - src_offset = etr_buf->offset + etr_buf->len - to_copy; > > while (to_copy > 0) { > /* > @@ -1475,7 +1471,7 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > void *config) > { > bool lost = false; > - unsigned long flags, size = 0; > + unsigned long flags, offset, size = 0; > struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); > struct etr_perf_buffer *etr_perf = config; > struct etr_buf *etr_buf = etr_perf->etr_buf; > @@ -1503,11 +1499,39 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > spin_unlock_irqrestore(&drvdata->spinlock, flags); > > size = etr_buf->len; > + offset = etr_buf->offset; > + lost |= etr_buf->full; > + > + /* > + * The ETR buffer may be bigger than the space available in the > + * perf ring buffer (handle->size). If so advance the offset so that we > + * get the latest trace data. In snapshot mode none of that matters > + * since we are expected to clobber stale data in favour of the latest > + * traces. > + */ > if (!etr_perf->snapshot && size > handle->size) { > - size = handle->size; > + u32 mask = tmc_get_memwidth_mask(drvdata); > + > + /* > + * Make sure the new size is aligned in accordance with the > + * requirement explained in function tmc_get_memwidth_mask(). > + */ > + size = handle->size & mask; > + offset = etr_buf->offset + etr_buf->len - size; > + > + if (offset >= etr_buf->size) > + offset -= etr_buf->size; > lost = true; > } > - tmc_etr_sync_perf_buffer(etr_perf, size); > + > + /* > + * Insert barrier packets at the beginning, if there was an overflow > + * or if the offset had to be brought forward. > + */ > + if (lost) > + tmc_etr_buf_insert_barrier_packet(etr_buf, offset); > + > + tmc_etr_sync_perf_buffer(etr_perf, offset, size); With this new code, the inserting barrier packet has been moved out from function tmc_sync_etr_buf(); but this patch doesn't handle the path when user uses SysFS node to access trace data and the trace buffer is also likely full, thus the SysFS mode might miss to insert barrier packets? Thanks, Leo Yan > /* > * In snapshot mode we simply increment the head by the number of byte > @@ -1518,7 +1542,6 @@ tmc_update_etr_buffer(struct coresight_device *csdev, > if (etr_perf->snapshot) > handle->head += size; > > - lost |= etr_buf->full; > out: > /* > * Don't set the TRUNCATED flag in snapshot mode because 1) the > -- > 2.17.1 >