Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp637729rwj; Thu, 22 Dec 2022 12:28:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+ArwVSAlarnu0EanrlBWEJ2NRl+zeM833FJ+x19UpHkotH12xcst4tomZS0nVSWNBGIw+ X-Received: by 2002:a17:90a:3941:b0:223:ed85:549 with SMTP id n1-20020a17090a394100b00223ed850549mr7709281pjf.45.1671740910686; Thu, 22 Dec 2022 12:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671740910; cv=none; d=google.com; s=arc-20160816; b=08ibcpwrTn38SMB2NcEBS61fxYpRNZvP+whYUpGPe816fLgqPDl3odEz+nIyxLV5xf W1U3Lai1E9a5ikGh5uR/EbXVqgkwowBJ4N6QobcCPONewpyKAp5eJTLpiUQhxZnGaLLz aMTLW9fgBmSfF9Y0uSRah0rkiQtmer+cHVpYL5sMSngRd6PuzD1Bu14RfEx4ennw7hG5 o1262dOtgdzOSQuSCNKe6IOXqfd+oGeoI87cAkS/6pFJ8sH5MtLmYfR8bF7lhOxFzTXQ 47a92T6U8aoK47+lNtoVu8fwT7v74zrDIcBxgxfs37qthgj2q9QhPPJswBCUuLbKm4eF JenA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4ytAB6GPau6OETGev83GGeIqSOa4ZbEhAW5OFieB3/Y=; b=zDRugjqpRFUYDLN2i8eiu85FIT0DYOGfv2fKkGQv1nr18jih3+VFmB+AuDSSP/dR1U 5KBq8qz7RVwizwYmvyiR6kb/4Ez0uz+vK092KTcWsfVNvq4GqWFEuIJ//OhbkdtrRIjo u8IBO0fi7iWxRxPxKmG8T/+w2IR+yr/AkNgP22DbRlBpxxjQ+UlsYSxyfmeBJ4eCF07V ameBbL4xWutWlUP1MvttRiRXQqWkvPAY2a1VDmHnPzCFBkfwbCS9/M9jzr0I7cXf+QKq i/6V3FL9yaL6LppRVLI4ge4znbbCew6p1qtZ9P8lTcCjLET/ld6GUxJGX8xvmaFu87+g dfUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nySFoWQr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x76-20020a63314f000000b004788e156154si1773939pgx.360.2022.12.22.12.28.21; Thu, 22 Dec 2022 12:28:30 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nySFoWQr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235438AbiLVUQa (ORCPT + 68 others); Thu, 22 Dec 2022 15:16:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiLVUQX (ORCPT ); Thu, 22 Dec 2022 15:16:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97548FD3D; Thu, 22 Dec 2022 12:16:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2259261D05; Thu, 22 Dec 2022 20:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17392C433D2; Thu, 22 Dec 2022 20:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671740181; bh=DMHA3b3oHIoMzIjLooyiE/VarbkUBMVQxKioBAYS5mw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nySFoWQrub2dY++C8/ToiEIR1HqSq6F5Geiaa4u5Scj+P+jEi10a21cF7Mb1wZpXZ RtVCZKgWak25BFC0ZGHtNzeNh32pb0pIxE9msHl1ufADSSej13HYGO8K8jLHrsZQyI fyssER6r1dHTpyuQFCUfQRCJ8dcgU7pYwx+aG05OkJLNPHy/m57xMW597IdXx4nNAQ ptIPs18Uqifua37kpXIuwUWBTAE259+AerS/kkQ6qZbd3otaD0JHwkGed2UJ8dXLXh NQLozAQRbxr3lfA2fSBXTjhmZA2Evb8arl5+VIZdzmQ13s5AUlD27t0y0U2VbLMRBA nZ2fJ5ZtAT4+g== Date: Thu, 22 Dec 2022 20:16:16 +0000 From: Conor Dooley To: Atish Kumar Patra Cc: Rob Herring , krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, Conor Dooley , devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, apatel@ventanamicro.com, Will Deacon , Mark Rutland , opensbi@lists.infradead.org Subject: Re: [PATCH v1] dt-bindings: riscv: add SBI PMU event mappings Message-ID: References: <20221221141548.274408-1-conor@kernel.org> <20221222180627.GA1748427-robh@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Z4/XEoq9i0wqaR4N" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 --Z4/XEoq9i0wqaR4N Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 22, 2022 at 11:55:29AM -0800, Atish Kumar Patra wrote: > On Thu, Dec 22, 2022 at 11:24 AM Conor Dooley wrote: > > On Thu, Dec 22, 2022 at 12:06:27PM -0600, Rob Herring wrote: > > > On Wed, Dec 21, 2022 at 02:15:49PM +0000, Conor Dooley wrote: > > > > From: Conor Dooley > > > > > > > > The SBI PMU extension requires a firmware to be aware of the event = to > > > > counter/mhpmevent mappings supported by the hardware. OpenSBI may u= se > > > > DeviceTree to describe the PMU mappings. This binding is currently > > > > described in markdown in OpenSBI (since v1.0 in Dec 2021) & used by= QEMU > > > > since v7.2.0. > > > > > > > > Import the binding for use while validating dtb dumps from QEMU and > > > > upcoming hardware (eg JH7110 SoC) that will make use of the event > > > > mapping. > > > > > > > > Link: https://github.com/riscv-software-src/opensbi/blob/master/doc= s/pmu_support.md > > > > Co-developed-by: Atish Patra > > > > Signed-off-by: Atish Patra > > > > Signed-off-by: Conor Dooley > > > > +description: | > > > > + SBI PMU extension supports allow supervisor software to configur= e, start & > > > > + stop any performance counter at anytime. Thus, a user can levera= ge full > > > > + capability of performance analysis tools such as perf if the SBI= PMU > > > > + extension is enabled. The OpenSBI implementation makes the follo= wing > > > > + assumptions about the hardware platform: > > > > + MCOUNTINHIBIT CSR must be implemented in the hardware. Otherwi= se, the SBI > > > > + PMU extension will not be enabled. > > > > + >=20 > This is no longer true since OpenSBI commit b28f070. We should remove > this from OpenSBI docs as well. Since you know the detail of it, I volunteer you for that one ;) > > > > + The platform must provide information about PMU event to count= er mapping > > > > + via device tree or platform specific hooks. Otherwise, the SBI= PMU > > > > + extension will not be enabled. > > > > + > > > > + The platforms should provide information about the PMU event s= elector > > > > + values that should be encoded in the expected value of MHPMEVE= NTx while > > > > + configuring MHPMCOUNTERx for that specific event. This can be = done via a > > > > + device tree or platform specific hooks. The exact value to be = written to > > > > + the MHPMEVENTx is completely dependent on the platform. The ge= neric > > > > + platform writes the zero-extended event_idx as the expected va= lue for > > > > + hardware cache/generic events as suggested by the SBI specific= ation. > > > > + >=20 > But the larger question is these are OpenSBI implementation specific > assumptions. Should it be included in > the DT binding? Probably not. I'll drop it for v2. > > > > +properties: > > > > + compatible: > > > > + const: riscv,pmu > > > > + > > > > + riscv,event-to-mhpmevent: > > > > + $ref: /schemas/types.yaml#/definitions/uint32-matrix > > > > + description: > > > > + Represents an ONE-to-ONE mapping between a PMU event and the= event > > > > + selector value that platform expects to be written to the MH= PMEVENTx CSR > > > > + for that event. > > > > + The mapping is encoded in an array format where each row rep= resents an > > > > > > s/array/matrix/ > > > > > > > + event. The first element represents the event idx while the = second & > > > > + third elements represent the event selector value that shoul= d be encoded > > > > + in the expected value to be written in MHPMEVENTx. > > > > + This property shouldn't encode any raw hardware event. > > > > + minItems: 1 > > > > + maxItems: 255 > > > > I copied these 255s from dt-schema somewhere as a sane max. > > Atish, is there a cap here or should we allow as many as someone likes? > > The md binding doesn't mention any limits - is it in the SBI spec? > > The strongest wording I saw there was "limited" & event idx is 20 bits > > wide as per the spec [0]. Does that make 2^20 the hard limit here? > > >=20 > This is for hardware & cache events. The total number of events > defined there are 52 (10 HW + 42 Cache) events. > So 255 is a sane max that provides enough room for expansion in future > if required. WFM. > > > > + riscv,raw-event-to-mhpmcounters: > > > > + $ref: /schemas/types.yaml#/definitions/uint32-matrix > > > > + description: > > > > + Represents an ONE-to-MANY or MANY-to-MANY mapping between th= e rawevent(s) > > > > + and all the MHPMCOUNTERx in a bitmap format that can be used= to monitor > > > > + that raw event. > > > > + The encoding of the raw events are platform specific. The in= formation is > > > > + encoded in an array format where each row represents the spe= cific raw > > > > + event(s). The first element is a 64-bit match value where th= e invariant > > > > + bits of range of events are set. The second element is a 64-= bit mask that > > > > + will have all the variant bits of the range of events cleare= d. All other > > > > + bits should be set in the mask. The third element is a 32-bi= t value to > > > > + represent bitmap of all MHPMCOUNTERx that can monitor these = set of > > > > + event(s). If a platform directly encodes each raw PMU event = as a unique > > > > + ID, the value of select_mask must be 0xffffffff_ffffffff. > > > > + minItems: 1 > > > > + maxItems: 255 > > > > + items: > > > > + $ref: /schemas/types.yaml#/definitions/uint32-array > > > > + maxItems: 5 > > > > + > > > > +required: > > > > + - compatible > > > > > > I assume at least one of the other properties must be present? > > > > Atish: (and +CC the OpenSBI list) > > Which properties are actually needed here? Or are any? The md binding > > in the OpenSBI sources doesn't seem to require anything other than the > > compatible? > > >=20 > That's true. Opensbi allows the platform to define functions > to provide the mapping. Now that's an OpenSBI implementation thing. > Other implementations may choose to use it differently. In the case where the platform can define functions, the "bare" node with just the compatible is still required though in that case, right? Thanks, Conor. --Z4/XEoq9i0wqaR4N Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCY6S7EAAKCRB4tDGHoIJi 0g2vAP9nEuTCVUKqyW74owqbj8+OZMHQcIeLAXuvNmpN4MR1cQD/Tq/Bn3SqRxBH OkW3HsXxbS3jEy6nw0LmAuq+6i5lKg4= =4o47 -----END PGP SIGNATURE----- --Z4/XEoq9i0wqaR4N--