From patchwork Wed Apr 21 12:04:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiss X-Patchwork-Id: 12216045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 307A5C433ED for ; Wed, 21 Apr 2021 12:07:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC6326140C for ; Wed, 21 Apr 2021 12:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC6326140C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nvFlTMQJUK2wp/ovpOkvIvp+GvakBurpDUHvQ1yeQrg=; b=dnzsNUT3k5L0cfmS8kLKeS3zI 5ElM/dMOTThnb5nZQeSdChkOfkNsgFWDb3d1kG0A4cRTS+odiSz5Y1jM30s1HMYWAozdt7pQfGfu/ Zsfg4nxw+GdfUWzsd8JMykBYlXZfHsGv8PHJVlsWCOKy2TH9Pj2TJYbt0niGi5ArGqr6JAbJbjolG O1GuL3BH++L+Se9W+33EVsN3DFjCsCykrUxi5IEiKPPLjZ7ArjB0b5WelSyEYdrN/qWX/M9VZAk3M PPOx7bf4RWzqkqyOogtDiZlu8vyIGqdGyG1xsldLtP5q19hNIvm0VD4KTcpEY+CRE7hkp3cUhLblP j3Cs/ORgw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZBbX-00ELoM-EV; Wed, 21 Apr 2021 12:05:15 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZBbD-00ELmx-I7 for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 12:04:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=04vr+WfDSmTH4e1GGR/cAOG29KP+Eq2W2copaLAyp1Y=; b=SLB2FtkwOr7fe7chXGkfAEg7iW W93VWNXObBgKArqrEa2+JHbOE5ZAvq2ZSnRPHprr3SqZhc79BC3l4bpYH/A3YhC7rBmTShGMinR1k 5rNTqiDxalvXsBwEMk4+e7tq734T7nSuA8dFxO+kXX/dpymHgYZ0NRHjk+yPv+XjkQFPS0srrW9uj qEp6HJ/axxVvKGQ/3eF48kSlG5g3U3Dp62faMzpcrBMQhEWVNb/P/hGPalyPc7jlmY7CKBGgG4TYz OBsd1jtoSA4+30BUVXzhGgZiVLcLedtvSYRlux72h4kTtAAB4XnNeL4uwHApoHBFbBf8AE3Q9/XHy Z9RJMj0Q==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZBb7-00CqzG-Od for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 12:04:54 +0000 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 BE40211FB; Wed, 21 Apr 2021 05:04:46 -0700 (PDT) Received: from e120529.arm.com (unknown [10.37.12.3]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 313573F694; Wed, 21 Apr 2021 05:04:45 -0700 (PDT) From: Daniel Kiss To: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org Cc: denik@google.com, Daniel Kiss , Branislav Rankov Subject: [PATCH 1/4] coresight: tmc-etr: Advance buffer pointer in sync buffer. Date: Wed, 21 Apr 2021 14:04:10 +0200 Message-Id: <20210421120413.3110775-2-daniel.kiss@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210421120413.3110775-1-daniel.kiss@arm.com> References: <20210421120413.3110775-1-daniel.kiss@arm.com> MIME-Version: 1.0 X-ARM-No-Footer: FoSSMail X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_050449_862421_8702CB8A X-CRM114-Status: GOOD ( 11.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With polling the sync could called multiple times in a row. Without this change the data will be overwritten at the beginning of the buffer. Signed-off-by: Daniel Kiss Signed-off-by: Branislav Rankov Reviewed-by: Leo Yan --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index ea5027e397d02..dd19d1d1c3b38 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1442,7 +1442,7 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, { long bytes; long pg_idx, pg_offset; - unsigned long head = etr_perf->head; + unsigned long head; char **dst_pages, *src_buf; struct etr_buf *etr_buf = etr_perf->etr_buf; @@ -1465,7 +1465,7 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, bytes = tmc_etr_buf_get_data(etr_buf, src_offset, to_copy, &src_buf); if (WARN_ON_ONCE(bytes <= 0)) - break; + return; bytes = min(bytes, (long)(PAGE_SIZE - pg_offset)); memcpy(dst_pages[pg_idx] + pg_offset, src_buf, bytes); @@ -1483,6 +1483,7 @@ static void tmc_etr_sync_perf_buffer(struct etr_perf_buffer *etr_perf, /* Move source pointers */ src_offset += bytes; } + etr_perf->head = (pg_idx << PAGE_SHIFT) + pg_offset; } /*