Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D19EC4332F for ; Wed, 23 Nov 2022 14:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wrw3gP9pB3JWqxoIuciUOG7ML9fT7jmM8+G2XfKrEoA=; b=dBnk2ivg/Ies70 S7H/RzcL1hgLmhH00nz/06TxhKXfS52rllwzp1/437Mcm+iWbOPf9BRREpz3G5PWuxiYSekMTyxdz YIkiHI1l8FCp+W245j4g1LFByW4Qk0pBNxnjANW3cbxox+lYiqf/+PyY/YSKq6t5vg+9FLvqTVqbd 8Ypgg0cg2gJhx8KEFXuxVJ7KXhMe33nsH+exuzF/j8xpakS2wk+oAM2F9AIGYCe5I4cThqQ51hvZI Nnvjz4XhWedBNuniE2sx7+GC4xtVn6oXiryGeSnr49NAyWckDZmqsXUlrn1EMa+YGVupE1yZQFzAA A3K87CsT2bNxR7TrRyNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxqLU-00HTR4-HU; Wed, 23 Nov 2022 14:03:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxqLQ-00HTPG-HY for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 14:03:22 +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 B551E1FB; Wed, 23 Nov 2022 06:03:24 -0800 (PST) Received: from [10.57.36.169] (unknown [10.57.36.169]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D81E23F73B; Wed, 23 Nov 2022 06:03:15 -0800 (PST) Message-ID: <9f5f66fa-0388-6a76-25c9-cacef0e7a4e2@arm.com> Date: Wed, 23 Nov 2022 14:03:14 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v14 1/2] drivers/coresight: Add UltraSoc System Memory Buffer driver To: Junhao He , mathieu.poirier@linaro.org, mike.leach@linaro.org, leo.yan@linaro.org, jonathan.cameron@huawei.com, john.garry@huawei.com Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, lpieralisi@kernel.org, linuxarm@huawei.com, yangyicong@huawei.com, liuqi6124@gmail.com, f.fangjian@huawei.com, prime.zeng@hisilicon.com References: <20221123123823.27973-1-hejunhao3@huawei.com> <20221123123823.27973-2-hejunhao3@huawei.com> From: Suzuki K Poulose In-Reply-To: <20221123123823.27973-2-hejunhao3@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_060320_707879_A6DC76B2 X-CRM114-Status: GOOD ( 21.43 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23/11/2022 12:38, Junhao He wrote: > From: Qi Liu > > Add driver for UltraSoc SMB(System Memory Buffer) device. > SMB provides a way to buffer messages from ETM, and store > these "CPU instructions trace" in system memory. > The SMB device is identifier as ACPI HID "HISI03A1". Device > system memory address resources are allocated using the _CRS > method and buffer modes is the circular buffer mode. > > SMB is developed by UltraSoc technology, which is acquired by > Siemens, and we still use "UltraSoc" to name driver. > > Signed-off-by: Qi Liu > Signed-off-by: Junhao He > Tested-by: JunHao He > Reviewed-by: Jonathan Cameron > --- > drivers/hwtracing/coresight/Kconfig | 12 + > drivers/hwtracing/coresight/Makefile | 1 + > drivers/hwtracing/coresight/ultrasoc-smb.c | 658 +++++++++++++++++++++ > drivers/hwtracing/coresight/ultrasoc-smb.h | 129 ++++ > 4 files changed, 800 insertions(+) > create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.c > create mode 100644 drivers/hwtracing/coresight/ultrasoc-smb.h > > +static void smb_sync_perf_buffer(struct smb_drv_data *drvdata, > + struct cs_buffers *buf, > + unsigned long head, > + unsigned long data_size) > +{ > + struct smb_data_buffer *sdb = &drvdata->sdb; > + char **dst_pages = (char **)buf->data_pages; > + unsigned long to_copy; > + long pg_idx, pg_offset; > + > + pg_idx = head >> PAGE_SHIFT; > + pg_offset = head & (PAGE_SIZE - 1); > + > + while (data_size) { > + unsigned long pg_space = PAGE_SIZE - pg_offset; > + > + /* Copy parts of trace data when read pointer wrap around */ > + if (sdb->rd_offset + pg_space > sdb->buf_size) > + to_copy = sdb->buf_size - sdb->rd_offset; > + else > + to_copy = min(data_size, pg_space); > + > + memcpy(dst_pages[pg_idx] + pg_offset, > + sdb->buf_base + sdb->rd_offset, to_copy); > + > + pg_offset += to_copy; > + if (pg_offset >= PAGE_SIZE) { > + pg_offset = 0; > + pg_idx++; > + pg_idx %= buf->nr_pages; > + } > + data_size -= to_copy; > + sdb->rd_offset += to_copy; > + sdb->rd_offset %= sdb->buf_size; > + } > + > + sdb->data_size = 0; --8>-- cut here --<8-- > + writel(sdb->start_addr + sdb->rd_offset, > + drvdata->base + SMB_LB_RD_ADDR_REG); > + > + /* > + * Data remained in link cannot be purged when SMB is full, so > + * synchronize the read pointer to write pointer, to make sure > + * these remained data won't influence next trace. > + */ > + if (sdb->full) { > + smb_purge_data(drvdata); > + writel(readl(drvdata->base + SMB_LB_WR_ADDR_REG), > + drvdata->base + SMB_LB_RD_ADDR_REG); > + } --<8-- end here --8>-- As pointed out in the last review, we must do this step everytime for perf mode irrespective of whether the buffer was "FULL" or not. i.e, the above block should simply be: if (sdb->full) smb_purge_data(drvdata); /* * The uncollected Data must be discarded for perf, * as it cannot be clubbed with next schedule. We * any way TRUNCATE the buffer in this case. */ writel(readl(drvdata->base + SMB_LB_WR_ADDR_REG), drvdata->base + SMB_LB_RD_ADDR_REG); Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel