Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp533080rwb; Thu, 10 Nov 2022 04:22:45 -0800 (PST) X-Google-Smtp-Source: AMsMyM5zuOsWTLO0As6c5m3pPxH+If6EUfAH3GQ8o5QllNQzdgHCk7inxCKzS+Y/Aqm5uXbtmXPT X-Received: by 2002:a65:6bcb:0:b0:44c:3e11:a7ac with SMTP id e11-20020a656bcb000000b0044c3e11a7acmr55561194pgw.274.1668082965561; Thu, 10 Nov 2022 04:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668082965; cv=none; d=google.com; s=arc-20160816; b=XILUKTQ5R1vd+SZBXGh64oZghvLTzVY7dLnG04uAqfDuqg1t/nuzNLOBmdovZHdH5C MjSy7CPgs4IixHth5o8AlIsNO34rSTDcy/90rB2D7X4XVkMh04CPlqCvLjai+8C3k+JD 8N8aNjCb+qpOOqLk5KGLVIXrBQkS+1wcSGtkawF5w6Tjl/YR8mcPopichvXnSSNyme3G 56rEiHtBOwAsxlOUJhU/o57SgraarBBEFJWwfoyjCDHkaxqb2x3VslpdG4HxudKCNRpv cbWbddevJF6PSbYErhBX4CJHHzwl442lvvQTLiQIzk0v3fLkSrcf4Hnbx5GSE1hNgxY/ wW3Q== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=oem5TDBRjjCJLU1evMpu6QpisHgkmSHUpjTWTs4li34=; b=gJ79sPxV9FrXZH7s7RnuayC3NGtiK7DuQz0HIXzDEgTRG1bpCoDG76aYwLj4CqTXfi 7dnGxBxOJEd01lHIO0S9gmB85HdY4q+PpkQpX+yTTuTOfV/imZHlZXOik7iQHVmk3Sa2 eeSdYZInAzVo3WzvpSNAKXWP61eqq2vPMuFBodBjT5x5B/YdOjky6b3hSwRYev5wEcKM fsSyyVigvmfpQRru8ob78W+rMHpdaV/J5ZOnQaYhjBE/x6hQ4hbjqvK2uQfv4mCbzLxQ 3cn+ds6PLSo6StOt6AYryTLPBKvBqAEqGgwy3ZR6Bgb8p4tEjib7l7jB0en494VsZCxC l7qw== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c20-20020a6566d4000000b0044601bb2f90si17873585pgw.530.2022.11.10.04.22.30; Thu, 10 Nov 2022 04:22:45 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229832AbiKJLNv (ORCPT + 92 others); Thu, 10 Nov 2022 06:13:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbiKJLNu (ORCPT ); Thu, 10 Nov 2022 06:13:50 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA83B6471 for ; Thu, 10 Nov 2022 03:13:47 -0800 (PST) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N7JzQ6drFzJnKW; Thu, 10 Nov 2022 19:10:42 +0800 (CST) Received: from dggpeml500002.china.huawei.com (7.185.36.158) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 19:13:45 +0800 Received: from [10.67.103.44] (10.67.103.44) by dggpeml500002.china.huawei.com (7.185.36.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 19:13:44 +0800 Subject: Re: [PATCH v12 1/2] drivers/coresight: Add UltraSoc System Memory Buffer driver To: Jonathan Cameron References: <20221109135008.9485-1-hejunhao3@huawei.com> <20221109135008.9485-2-hejunhao3@huawei.com> <20221109165615.00006060@Huawei.com> CC: , , , , , , , , , , , , From: hejunhao Message-ID: <025f4daf-b5c6-e70e-977d-f475a6aae8ef@huawei.com> Date: Thu, 10 Nov 2022 19:13:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20221109165615.00006060@Huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.44] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500002.china.huawei.com (7.185.36.158) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2022/11/10 0:56, Jonathan Cameron wrote: > On Wed, 9 Nov 2022 21:50:07 +0800 > Junhao He wrote: > >> From: Qi Liu >> >> This patch adds 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. >> >> 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 > Hi JunHao, > > One trivial side effect of dropping the ACPI dependency. > > Also, I think (at the cost of a slightly lengthening of lines) > you can rename the register fields to avoid any potential > confusion between GLB and LB registers. > > With those fixed feel free to add > > Reviewed-by: Jonathan Cameron > Hi Jonathan, Thanks for you comments! I will fix these in the next version. Thanks. > > ... > >> diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing/coresight/ultrasoc-smb.c >> new file mode 100644 >> index 000000000000..ea2552a98d28 >> --- /dev/null >> +++ b/drivers/hwtracing/coresight/ultrasoc-smb.c > ... > >> +static const struct acpi_device_id ultrasoc_smb_acpi_match[] = { >> + {"HISI03A1", 0}, >> + {} >> +}; >> +MODULE_DEVICE_TABLE(acpi, ultrasoc_smb_acpi_match); >> + >> +static struct platform_driver smb_driver = { >> + .driver = { >> + .name = "ultrasoc-smb", >> + .acpi_match_table = ACPI_PTR(ultrasoc_smb_acpi_match), > Now the driver build isn't dependent on CONFIG_ACPI > if !CONFIG_ACPI ACPI_PTR() doesn't reference the parameter. > As such you'll get unused warnings. > > 1 options to fix this > a) Drop ACPI_PTR() and just have .acpi_match_data = ultrasoc_smb_acpi_match > b) ifdef magic around the acpi_match table. > > In theory the first option results in bloat, but in this case I doubt we care. Ok, will fix it, as follows ``` #ifdef CONFIG_ACPI static const struct acpi_device_id ultrasoc_smb_acpi_match[] = { {"HISI03A1", 0}, {} }; MODULE_DEVICE_TABLE(acpi, ultrasoc_smb_acpi_match); #endif ``` >> + .suppress_bind_attrs = true, >> + }, >> + .probe = smb_probe, >> + .remove = smb_remove, >> +}; >> +module_platform_driver(smb_driver); >> + >> +MODULE_DESCRIPTION("UltraSoc SMB CoreSight driver"); >> +MODULE_LICENSE("Dual MIT/GPL"); >> +MODULE_AUTHOR("Jonathan Zhou "); >> +MODULE_AUTHOR("Qi Liu "); >> diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.h b/drivers/hwtracing/coresight/ultrasoc-smb.h >> new file mode 100644 >> index 000000000000..2e2f9f8fe54b >> --- /dev/null >> +++ b/drivers/hwtracing/coresight/ultrasoc-smb.h >> @@ -0,0 +1,116 @@ >> +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ >> +/* >> + * Siemens System Memory Buffer driver. >> + * Copyright(c) 2022, HiSilicon Limited. >> + */ >> + >> +#ifndef _ULTRASOC_SMB_H >> +#define _ULTRASOC_SMB_H >> + >> +#include >> +#include >> + >> +/* Offset of SMB global registers */ >> +#define SMB_GLB_CFG_REG 0x00 >> +#define SMB_GLB_EN_REG 0x04 >> +#define SMB_GLB_INT_REG 0x08 >> + >> +/* Offset of SMB logical buffer registers */ >> +#define SMB_LB_CFG_LO_REG 0x40 >> +#define SMB_LB_CFG_HI_REG 0x44 >> +#define SMB_LB_INT_CTRL_REG 0x48 >> +#define SMB_LB_INT_STS_REG 0x4c >> +#define SMB_LB_RD_ADDR_REG 0x5c >> +#define SMB_LB_WR_ADDR_REG 0x60 >> +#define SMB_LB_PURGE_REG 0x64 >> + >> +/* Set global config register */ >> +#define SMB_CFG_BURST_LEN_MSK GENMASK(11, 4) > Given there are several CFG registers, possibly worth > prefix of SMB_GLB_CFG_ ... Sure, I will do that. >> +#define SMB_CFG_IDLE_PRD_MSK GENMASK(15, 12) >> +#define SMB_CFG_MEM_WR_MSK GENMASK(21, 16) >> +#define SMB_CFG_MEM_RD_MSK GENMASK(27, 22) >> +#define SMB_GLB_CFG_DEFAULT (FIELD_PREP(SMB_CFG_BURST_LEN_MSK, 0xf) | \ >> + FIELD_PREP(SMB_CFG_IDLE_PRD_MSK, 0xf) | \ >> + FIELD_PREP(SMB_CFG_MEM_WR_MSK, 0x3) | \ >> + FIELD_PREP(SMB_CFG_MEM_RD_MSK, 0x1b)) >> + >> +/* Set global interrupt control register */ >> +#define SMB_INT_EN BIT(0) > Again, multiple INT registers, so SMB_INT_GLB_* perhaps? Ok, will fix it. >> +#define SMB_INT_PULSE BIT(1) /* Interrupt type: 1 - Pulse */ >> +#define SMB_INT_ACT_H BIT(2) /* Interrupt polarity: 1 - Active high */ >> +#define SMB_GLB_INT_CFG (SMB_INT_EN | SMB_INT_PULSE | SMB_INT_ACT_H) >> + >> +/* Set logical buffer config register lower 32 bits */ >> +#define SMB_CFG_LO_EN BIT(0) > SMB_LB_CFG_... > > etc for other cases. Sure, I will do that. >> +#define SMB_CFG_LO_SINGLE_END BIT(1) >> +#define SMB_CFG_LO_INIT BIT(8) >> +#define SMB_CFG_LO_CONT BIT(11) >> +#define SMB_CFG_LO_FLOW_MSK GENMASK(19, 16) >> +#define SMB_LB_CFG_LO_DEFAULT (SMB_CFG_LO_EN | SMB_CFG_LO_SINGLE_END | \ >> + SMB_CFG_LO_INIT | SMB_CFG_LO_CONT | \ >> + FIELD_PREP(SMB_CFG_LO_FLOW_MSK, 0xf)) >> + >> +/* Set logical buffer config register upper 32 bits */ >> +#define SMB_CFG_HI_RANGE_UP_MSK GENMASK(15, 8) >> +#define SMB_LB_CFG_HI_DEFAULT FIELD_PREP(SMB_CFG_HI_RANGE_UP_MSK, 0xff) >> + >> +/* Set logical buffer interrupt control register */ >> +#define SMB_INT_CTRL_EN BIT(0) >> +#define SMB_INT_CTRL_BUF_NOTE_MSK GENMASK(11, 8) >> +#define SMB_LB_INT_CTRL_CFG (SMB_INT_CTRL_EN | \ >> + FIELD_PREP(SMB_INT_CTRL_BUF_NOTE_MSK, 0xf)) >> + >> +#define SMB_LB_INT_STS_NOT_EMPTY_MSK BIT(0) >> +#define SMB_LB_STS_RESET_MSK GENMASK(3, 0) >> +#define SMB_LB_INT_BUF_STS_RESET FIELD_PREP(SMB_LB_STS_RESET_MSK, 0xf) >> +#define SMB_LB_PURGE_PURGED BIT(0) >> +#define SMB_GLB_EN_HW_ENABLE BIT(0) >> + >> +#define SMB_REG_ADDR_RES 0 >> +#define SMB_BUF_ADDR_RES 1 >> +#define SMB_BUF_ADDR_LO_MSK GENMASK(31, 0) > ... > >> + >> +/** >> + * struct smb_drv_data - specifics associated to an SMB component >> + * @base: Memory mapped base address for SMB component. >> + * @csdev: Component vitals needed by the framework. >> + * @sdb: Data buffer for SMB. >> + * @miscdev: Specifics to handle "/dev/xyz.smb" entry. >> + * @mutex: Control data access to one at a time. >> + * @reading: Synchronise user space access to SMB buffer. >> + * @pid: Process ID of the process being monitored by the >> + * session that is using this component. >> + * @mode: how this SMB is being used, perf mode or sysfs mode. > Trivial, but for consistency should be: How this... Yes, I will do that. >> + */ >> +struct smb_drv_data { >> + void __iomem *base; >> + struct coresight_device *csdev; >> + struct smb_data_buffer sdb; >> + struct miscdevice miscdev; >> + struct mutex mutex; >> + local_t reading; >> + pid_t pid; >> + u32 mode; >> +}; >> + >> +#endif > . > Best regards, Junhao.