Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7451685rwb; Wed, 23 Nov 2022 06:45:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gcfaCYLM71aIcT5OhH1VoijRLIkzFQ+tLUZ5S2/rnhxup/mWL2E9MeR4KgHXAL9I/ABX2 X-Received: by 2002:a05:6402:3893:b0:461:b033:90ac with SMTP id fd19-20020a056402389300b00461b03390acmr14079087edb.257.1669214708861; Wed, 23 Nov 2022 06:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669214708; cv=none; d=google.com; s=arc-20160816; b=BRFJykbW4oaPeJBDEC+YTehEVjMjhfVq+S/b6nymRFk9dwu044zT3PDToIAx06a8uJ mZO37TIxViy5b5OX2DUX1uCDJ+k+V8eT2h/Rp9q2KmQ1zL4MqgeLvurNU7koeO5T4NAN HfF+0Qid+1yaGOvsfbTtMlM2muoC9PPn129bTjtuSenyGAfQMuAqZJBvFn4LkQpPaist FTJU2PlFR9iFETq7rjAqYWqQ/nsx7qJVdnPdNMmwBz+NqT+R1Qm28ZuDqvy8dH6Pvc91 y5/W1EBsZu0xDbPJxbpjL0qy1lMJm6KPIW3qzdhVnRRWUykUHz68MbgEJ/UiR02x7odu jPOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=RyYFcJtht40cNgMhk7VG7N15ESa9ajyxzFY2PESAshY=; b=JIKQvQ2iUG3ocHXnHtmBlgFC1OLwFNHWcST1t7wj6KCJuDRQ5kOKTqwB6H53DZ9mJy DQp8bEMJa+cKaHd2wSikhN5LsfptKnv7FObYBxV8ytwEn4BkR/hCBnGBqGpuFtEzsa5l ha8Og57hu2cLeNtRaxNfaKk3R0ibjkd1rgmPtfhNjKOfY4ey2i5w/XGdDwYEAIsdKx5J decFhgQwSBumRq16JdxIoqp7dQm3pKPRlFJmLztVir1gXORAtTRorzBn/07L2QljD1LP tCqGUd7LDabhnonfniitQEWT2m9UMcp9d3kK3H2Ckp717KSb72729dQqaFcEWYi4oMBA qJYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a05640210d000b0046920e7030csi293747edu.222.2022.11.23.06.44.45; Wed, 23 Nov 2022 06:45:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237836AbiKWOHx (ORCPT + 88 others); Wed, 23 Nov 2022 09:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238401AbiKWOGy (ORCPT ); Wed, 23 Nov 2022 09:06:54 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1C36D85A18; Wed, 23 Nov 2022 06:03:18 -0800 (PST) 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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