Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1543732rdb; Wed, 31 Jan 2024 01:38:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcYuYB1IbWu7pW1XONXvPtdcP3o1705/dwmFLTwCLjasSTxW1/7ONRCMzyafQPBWLaRviK X-Received: by 2002:a05:622a:f:b0:42a:b21e:e7f4 with SMTP id x15-20020a05622a000f00b0042ab21ee7f4mr1100315qtw.24.1706693932864; Wed, 31 Jan 2024 01:38:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXmsi+xdcpcR6FA59E3nVIsJP/r7d6AiGKqbwn+f10Tw16Arh1TGBr9H5vuAtadFHw3XM1WxgDPb5ciwZvIniS2iynz9x1APaekDIjErQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a5-20020ac85b85000000b0042a5bd82617si11989078qta.321.2024.01.31.01.38.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:38:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46150-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=O87DrViM; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-46150-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 78A251C25BAD for ; Wed, 31 Jan 2024 09:38:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 217EE69941; Wed, 31 Jan 2024 09:38:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O87DrViM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3F3269944 for ; Wed, 31 Jan 2024 09:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706693927; cv=none; b=ipnpD6gHenelH+7ndZqY/0CKmY3MKSDtCTF9CytAlBMTZuOrFBGlElWSeFz85jYZNZYbctcheKSLhQcXhGze7XXpbwzFhQxlbiteoSTKpwB/1dlVtk8GxKZ/WPclQPo6DYljZ62GnsYF/k7yCkY4Cm0tTrYrPsx9lM9W47JVMaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706693927; c=relaxed/simple; bh=ueZ1o/qp07S1jEAUT0lMHJpeLaZtwe2Yg+6xj7z1b3o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=OF42fA2sgCugGh09ziNJmiediQxi0XR+Y0rHaw/iJ4bELmwiX/jrqp18qEP7alxxUGhI5Bi2OyzpnCTzXaBKAtoI5ybVZn7vjlEGxGcYvFfhC8FAPiKXg5bfXi2ioenkkwdAKQogeE3CRIMdOjEQNoYcF/uD8YOsr4GZjTrBQic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O87DrViM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE7A6C433F1; Wed, 31 Jan 2024 09:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706693926; bh=ueZ1o/qp07S1jEAUT0lMHJpeLaZtwe2Yg+6xj7z1b3o=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=O87DrViMDk5TcT7Q7hwDQ0sM724YLBeuKJbBXXOCvg8lhRh/VoFVsXjale1r48HWC 84t7wR5ahz/MiToQtf3TT5ECPWaHx9z+u+QVZqvKG5L0Cjy5n/MWox6EWjoR66JRCE 1EOdpu4Ya6Naa7uhcFTTaUSKYmhIIP4fkHQfW2BJgDCQ+MwPYS50JpY9bj0lY+QeGc ju1TcvDtX4NcAIN7Q05QWrA+goftJ2ge0O1aWZ9lNo4z1a9piujBcDTUT55OaHZnJ0 h/HwUCHGIRoH3Yec3pawlrTOuEdffCvk+Vw5MVtssB3sP1vysbkG2zk/mTQbEO/Z8a 5YU0Y+66Ftg9A== Message-ID: Date: Wed, 31 Jan 2024 10:38:39 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] perf/hx_arm_ni: Support uncore ARM NI-700 PMU Content-Language: en-US To: =?UTF-8?B?WWFuZyBKaWFsb25nIOadqOS9s+m+mQ==?= , Will Deacon , Mark Rutland Cc: shenghui.qu@shingroup.cn, ke.zhao@shingroup.cn, zhijie.ren@shingroup.cn, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240131070821.11477-1-jialong.yang@shingroup.cn> <6D9001324476F76F+ee5f853d-7c69-4a99-857c-cc2b03e9eea1@shingroup.cn> From: Krzysztof Kozlowski Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bC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oFzZ4B0p27K+qQCF2R96hVvuEyjzBmdq2esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: <6D9001324476F76F+ee5f853d-7c69-4a99-857c-cc2b03e9eea1@shingroup.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 31/01/2024 10:07, Yang Jialong 杨佳龙 wrote: > > > 在 2024/1/31 15:59, Krzysztof Kozlowski 写道: >> On 31/01/2024 08:08, JiaLong.Yang wrote: >>> This code is based on uncore PMUs arm_smmuv3_pmu and arm-cmn. >>> One ni-700 can have many clock domains. Each of them has only one PMU. >>> Here one PMU corresponds to one 'struct ni_pmu' instance. >>> PMU name will be ni_pmu_N_M, which N means different NI-700s and M means >>> different PMU in one NI-700. If only one NI-700 found in NI-700, name will >>> be ni_pmu_N. >>> Node interface event name will be xxni_N_eventname, such as >>> asni_0_rdreq_any. There are many kinds of type of nodes in one clock >>> domain. Also means that there are many kinds of that in one PMU. So we >>> distinguish them by xxni string. Besides, maybe there are many nodes >>> have same type. So we have number N in event name. >>> By ni_pmu_0_0/asni_0_rdreq_any/, we can pinpoint accurate bus traffic. >>> Example1: perf stat -a -e ni_pmu_0_0/asni_0_rdreq_any/,ni_pmu_0_0/cycles/ >>> EXample2: perf stat -a -e ni_pmu_0_0/asni,id=0,event=0x0/ >>> >>> Signed-off-by: JiaLong.Yang >>> --- >>> v1 --> v2: >>> 1. Submit MAINTANER Documentation/ files seperately. >> >> SEPARATE PATCHES, not patchsets. You have now checkpatch warnings >> because of this... > > ...OK. But the MAINTANER file changing should be given in which one > patches. > I will submit patch v3 after talking and your permission. > >> >>> 2. Delete some useless info printing. >>> 3. Change print from pr_xxx to dev_xxx. >>> 4. Fix more than 75 length log info. >>> 5. Fix dts attribute pccs-id. >>> 6. Fix generic name according to DT specification. >>> 7. Some indentation. >>> 8. Del of_match_ptr macro. >>> >>> drivers/perf/Kconfig | 11 + >>> drivers/perf/Makefile | 1 + >>> drivers/perf/hx_arm_ni.c | 1284 ++++++++++++++++++++++++++++++++++++++ >>> 3 files changed, 1296 insertions(+) >>> create mode 100644 drivers/perf/hx_arm_ni.c >>> >>> diff --git a/drivers/perf/Kconfig b/drivers/perf/Kconfig >>> index ec6e0d9194a1..95ef8b13730f 100644 >>> --- a/drivers/perf/Kconfig >>> +++ b/drivers/perf/Kconfig >>> @@ -241,4 +241,15 @@ config CXL_PMU >>> >>> If unsure say 'm'. >>> >>> +config HX_ARM_NI_PMU >>> + tristate "HX ARM NI-700 PMU" >>> + depends on PPC_HX_C2000 && 64BIT >> >> 1. There is no PPC_HX_C2000. > > I have been used to using this macro. However this macro is not existed > in mainline. > I will replace it with ARM64. And del involved C code if OK. > > 64bit: > __ffs(unsigned long) and __fls(unsigned long) will be wrong in 32bit. I > pass a u64 argument. One thing is where the code is supposed to run, second thing is compile testing. Why do you use __ffs, not __ffs64 which takes u64 if you really want only 64bit argument? unsigned long != u64, so your code is not architecture independent. You claim you wrote it on purpose as non-architecture-independent, but then I claim it's a bug. We are supposed to write code which is portable, as much as possible, assuming it does not affect readability. > struct ni_hw_perf_event will be big than limit. > BUILD_BUG_ON(sizeof(struct ni_hw_perf_event) > offsetof(struct > hw_perf_event, target)); And why do you need to use any of such code? Please open one of hundreds of other drivers which work correctly on 32 and 64-bit platforms. > >> 2. Nothing justified dependency on 64bit. Drop or explain. Your previous >> message did not provide real rationale. > > If ARM64, then drop. .. .. >>> + /* Step2: Traverse all clock domains. */ >>> + for (cd_idx = 0; cd_idx < ni->cd_num; cd_idx++) { >>> + cd = cd_arrays[cd_idx]; >>> + >>> + num = ni_child_number(cd); >>> + dev_dbg(dev, "The %dth clock domain has %d child nodes:", cd_idx, num); >>> + >>> + /* Omit pmu node */ >>> + ni_pmu = devm_kzalloc(dev, struct_size(ni_pmu, ev_src_nodes, num - 1), >>> + GFP_KERNEL); >>> + ni_pmu->ev_src_num = num - 1; >>> + >>> + if (!ni_pmu) >>> + return -ENOMEM; >>> + >>> + num_idx = 0; >>> + for (nd_idx = 0; nd_idx < num; nd_idx++) { >>> + nd = ni_child_pointer(pbase, cd, nd_idx); >>> + >>> + node.base = nd; >>> + node.node_type = ni_node_node_type(nd); >>> + >>> + if (unlikely(ni_node_type(nd) == NI_PMU)) >>> + ni_pmu->pmu_node = node; >>> + else >>> + ni_pmu->ev_src_nodes[num_idx++] = node; >>> + dev_dbg(dev, " name: %s id: %d", ni_node_name[node.type], node.id); >>> + } >>> + >>> + ni_pmu->dev = dev; >>> + ni_pmu->ni = ni; >>> + ni->ni_pmus[cd_idx] = ni_pmu; >>> + } >>> + >>> + devm_kfree(dev, cd_arrays); >> >> Why? If it is not device-lifetime then allocate with usual way. >> > > No device-lifetime. > Will allocate in stack. I was thinking about kzalloc. But if array is small, stack could be as well. .. >> >>> + >>> +static const struct of_device_id ni_pmu_of_match[] = { >>> + { .compatible = "hx,c2000-arm-ni" }, >> >> Don't send undocumented compatibles. > > OK. Means I should send doc and code in one patch thread with more than > one patch? Yes. Please open lore.kernel.org and look at any other submissions involving bindings or other type of ABI documentation (like sysfs). Best regards, Krzysztof