From patchwork Thu Apr 20 17:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 85990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp523697vqo; Thu, 20 Apr 2023 11:10:21 -0700 (PDT) X-Google-Smtp-Source: AKy350YUdGbIPH10n/ltuU+FnLjCxYSb5hu0eg8bPQtPj9Sm1iNWM4HASHQsHXtmcS75gyeEgcn/ X-Received: by 2002:a05:6a20:734f:b0:ec:e221:be4b with SMTP id v15-20020a056a20734f00b000ece221be4bmr3539853pzc.21.1682014221589; Thu, 20 Apr 2023 11:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682014221; cv=none; d=google.com; s=arc-20160816; b=AlyMCi2hgDMi+Pih1CkWjKjg4YLuUZae618poWkdwfG7VoeOGx5ZXaK6hwp0dgFR/e z/0PXQK4XjyWNeRcVkVLeN7hOHh+4MoiOuRuq4Z130OsVZFlbWms/YeN6aJS8KZxEX5c 3y+xuY4tnTxCaljmx3kn7KbyIhJiUdxC1pkPXIUdDeFg8xkQUzCntGSJlBNSFkleVey5 EyDtl4B8ZLK43bohmwScaPtMc2RiwSE+9LMFPd26osTrVPib8aEZ5o31Sp3a2AGIREkH CtNz3nOQ3r/PGiOQqJ+UBsoNtV/EXmq8iRqJ2HgHZfdUiRs0m6rpKo3ZNLjIq84Dx9xs 8CHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=luGj539pp3UeKX7ZE1UY5I+Ghz8yELYDvW80PLWj8ZM=; b=v/3izUtt4M0W00CHyxLqanN0Xx3U0IKu1ELsmkUX8zSdLC8KR1m4JxGYSi/BfLWpOH WV2BocH0gWyoyH9LNVdJqolT8+Emas5wlKYvzxoluGSTZ++aTVStkZ6tZU/dlcV2fAjq siNz9iO/jOgfywrO0GoJEHU0NcjHZ8eVJgnzncOxQBTYKzQo9vZkOQJxVuonDzMi16U+ 4QXrVZ93QpwJiFixVCj6Y7Um8Ml2SM1TRn/1CQQR6fhw1ImJzuTv2FttoMM33+U1ZuyS 6adxSDAZdhWEBtUvMg24WCo0IVyfMryz4b6e3AggbqgLMW8pTaZmXedqzn5baOehqwjC HEkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TpN1j+9c; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020aa78ec9000000b0063b8935bcbasi2009398pfr.310.2023.04.20.11.10.06; Thu, 20 Apr 2023 11:10:21 -0700 (PDT) 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=@linaro.org header.s=google header.b=TpN1j+9c; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbjDTRg2 (ORCPT + 99 others); Thu, 20 Apr 2023 13:36:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbjDTRgZ (ORCPT ); Thu, 20 Apr 2023 13:36:25 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9529544AF for ; Thu, 20 Apr 2023 10:36:23 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4ec817735a7so686489e87.3 for ; Thu, 20 Apr 2023 10:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682012182; x=1684604182; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=luGj539pp3UeKX7ZE1UY5I+Ghz8yELYDvW80PLWj8ZM=; b=TpN1j+9cbp1/xk4eHnPogF47p/38uEqFoUu2zRmxb+U/FGKBuXBIgWxVJD7W8oQ3Dz jvWN6Byzi42MOfyA83MTSrFptYQKQliBX7WhP4MmQH4DCqcirpSTq9R+Mmc6Y6OTWxU0 EYxWK6au7jNKNRd6JyPxrk89XPxx5BXjMEIoxyq1G3XVrMXprsPZT1QGelPJ+asBejco pz4crJW36GhnFRAb2HS9FwSD0u4FQvASypBsBB7OG+OaiZDMSgFsKakCSh9c59oqoyiz QnKJa57dscq+rtK609zxxCwMna/SZ9JX9EMth9TMF/lu2y/QroRBwBpkevZGRYy9VnEr oBEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682012182; x=1684604182; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=luGj539pp3UeKX7ZE1UY5I+Ghz8yELYDvW80PLWj8ZM=; b=Vjf023v2M57IuczMwnW8q0VxJled6Q0aYcauQ9fwuipAEulYOZMWMyTfhNEcJMt1pW cGWALnYeIlitBqn2cZT8aghpAw/ddtRofwoGkI6+CguGJskobVkOHjmr5MvqH7t+JjRw zub9s/JRq3BoM7l87H5lt/GezXv2C+bqFWuppaa7wg6xr4yfvfpEOMj99hKlb148npCC L+L2vnaklyWvFPyUo8SH+/1jQwybR/ahwIOHflJ4opavxRbwl6cKq9N6gjIGfx7oSjfA BAVc7EJYgV/VMq13Cxe355xWJeeEDzLv+1ITP16NP3+TH7D9CDl+Gm6bjcivq62+dIrr tk6A== X-Gm-Message-State: AAQBX9cM6H+CX83lA/6HOVvfYrx9KiAgZCfoWg8lLCXzMzwHBCRKsYiw GaLgE8tULqF6eGyT0rp7FohoSQ== X-Received: by 2002:a05:6512:4c9:b0:4da:fb89:fcc6 with SMTP id w9-20020a05651204c900b004dafb89fcc6mr582923lfq.57.1682012181767; Thu, 20 Apr 2023 10:36:21 -0700 (PDT) Received: from [192.168.1.101] (abyj144.neoplus.adsl.tpnet.pl. [83.9.29.144]) by smtp.gmail.com with ESMTPSA id l16-20020ac25550000000b004edc16dbdfasm281336lfk.119.2023.04.20.10.36.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 10:36:21 -0700 (PDT) From: Konrad Dybcio Date: Thu, 20 Apr 2023 19:36:17 +0200 Subject: [PATCH v6 1/2] dt-bindings: soc: qcom: Add RPM Master stats MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v6-1-2277b4433748@linaro.org> References: <20230405-topic-master_stats-v6-0-2277b4433748@linaro.org> In-Reply-To: <20230405-topic-master_stats-v6-0-2277b4433748@linaro.org> To: Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Manivannan Sadhasivam , Krzysztof Kozlowski X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1682012179; l=3243; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=q81J4A/2z95qbACyYEJZy5TUp/FHfxF8n9PZuxO8IRM=; b=uGmg9eoUXmGK9YUe5u0buP48X6jodud90A1QBh1pC2u5UDcHRP6soBLxgVllESU0HAVHWFm+KBN9 ODlk2Vy0CLz0FBQyF2NRRpoCk94iQHXpGNjpqN31Nv+XYnXUCr5U X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763719744338497707?= X-GMAIL-MSGID: =?utf-8?q?1763719744338497707?= The RPM MSG RAM contains per-RPM-master (e.g. APPS, ADSP etc.) sleep statistics. They let one assess which core is actively preventing the system from entering a true low-power mode. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Konrad Dybcio --- .../bindings/soc/qcom/qcom,rpm-master-stats.yaml | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,rpm-master-stats.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,rpm-master-stats.yaml new file mode 100644 index 000000000000..031800985b5e --- /dev/null +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,rpm-master-stats.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/qcom/qcom,rpm-master-stats.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies, Inc. (QTI) RPM Master Stats + +maintainers: + - Konrad Dybcio + +description: | + The Qualcomm RPM (Resource Power Manager) architecture includes a concept + of "RPM Masters". They can be thought of as "the local gang leaders", usually + spanning a single subsystem (e.g. APSS, ADSP, CDSP). All of the RPM decisions + (particularly around entering hardware-driven low power modes: XO shutdown + and total system-wide power collapse) are first made at Master-level, and + only then aggregated for the entire system. + + The Master Stats provide a few useful bits that can be used to assess whether + our device has entered the desired low-power mode, how long it took to do so, + the duration of that residence, how long it took to come back online, + how many times a given sleep state was entered and which cores are actively + voting for staying awake. + + This scheme has been used on various SoCs in the 2013-2023 era, with some + newer or higher-end designs providing this information through an SMEM query. + +properties: + compatible: + const: qcom,rpm-master-stats + + qcom,rpm-msg-ram: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: Phandle to an RPM MSG RAM slice containing the master stats + minItems: 1 + maxItems: 5 + + qcom,master-names: + $ref: /schemas/types.yaml#/definitions/string-array + description: + The name of the RPM Master which owns the MSG RAM slice where this + instance of Master Stats resides + minItems: 1 + maxItems: 5 + +required: + - compatible + - qcom,rpm-msg-ram + - qcom,master-names + +additionalProperties: false + +examples: + - | + stats { + compatible = "qcom,rpm-master-stats"; + qcom,rpm-msg-ram = <&apss_master_stats>, + <&mpss_master_stats>, + <&adsp_master_stats>, + <&cdsp_master_stats>, + <&tz_master_stats>; + qcom,master-names = "APSS", + "MPSS", + "ADSP", + "CDSP", + "TZ"; + }; +... From patchwork Thu Apr 20 17:36:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 85983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp506311vqo; Thu, 20 Apr 2023 10:38:49 -0700 (PDT) X-Google-Smtp-Source: AKy350aE/uweoZ1+NZpd62ywQUsE6yVqmTq5gCLlVquWfcziy0JkSwOVV4DrNMbxQhVVGY0UK61F X-Received: by 2002:a17:90a:8a91:b0:246:9932:18a2 with SMTP id x17-20020a17090a8a9100b00246993218a2mr2327383pjn.31.1682012329178; Thu, 20 Apr 2023 10:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682012329; cv=none; d=google.com; s=arc-20160816; b=IVUTvHAPT0YhFjD9yAvzu6k2yF2aaZ9yJpyvOMtFKBRm0QdspibfjU8AaXUZhrG9e/ ZFMRhaQEAj/fxj9LOca+tNUTKFxnygkByxzwR6q6s9kIW3FhqREv9o/7vvXQcthSmhHF pHdcauuTiae5FIJ+XB6ivXbw6TafX/d31KwM0ChTq/lfHcIDNHjsHhSGbiuMlbl0dX/d gRXp5LNpRrATmWt+Lq5U9UPF6VtxqPADaIzXqQvenOBnSnrEN5llfed6G2ZqRCBLuFa1 gSsQzxRj6zW9LS/AbDGFbHYgpKP+su9TVe8cMrpa1MqYCWQCGqtRMbRb2YX+l0ezzuKv yGFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=z2JgYL8DkZMdzf2YexeAn4MdqBHMsfy9XvbP/7e9/AQ=; b=XwmN42DrhXX5GZTwZ2hZKFImemLsJn1dwaTWofEJFeKN0Gj6+15g8xkIofyIbMHsPr oITlhJjHGtLPJVvHuxIdrJZFOk5BGUiiZF9TIHjrB51tp4RSEgev7U73WxJyf/jm8Sbo TWiFK2Sk+nBTSbZN8HEOpUliOgn1XX4ScDEDUCIzJdypdR3zQvKXUK75w9253UpSrfel pBjqK+DPY9i1HluGjSI5FnOQINqv427NlG388YgmGyre+ZoLnEj+JdtNY4Y/V+nhg0fi JRzOOTLBgBlu0bo4dU+lpxaHL9/77f4v5QWMyK0QV2WPnRsdUvaGClI/Fy8wYJh7ekBK Mkig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XQCn7SOY; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a17090ac70500b0024b5a028e7asi767986pjt.47.2023.04.20.10.38.34; Thu, 20 Apr 2023 10:38:49 -0700 (PDT) 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=@linaro.org header.s=google header.b=XQCn7SOY; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbjDTRgb (ORCPT + 99 others); Thu, 20 Apr 2023 13:36:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjDTRg0 (ORCPT ); Thu, 20 Apr 2023 13:36:26 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBD4946A6 for ; Thu, 20 Apr 2023 10:36:24 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4ec9c7c6986so719139e87.0 for ; Thu, 20 Apr 2023 10:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682012183; x=1684604183; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=z2JgYL8DkZMdzf2YexeAn4MdqBHMsfy9XvbP/7e9/AQ=; b=XQCn7SOY/i6cn7NYPdefnb8vqllseGwIvoR5J1/szy7kn93oLrd5lnmYFwJzP65S+m BMFmnIIWy6VB+CO5Qu4/7brRaZd7GH39UlYZJGbXCMHln3zyVpP2zhvuzUN25Wjm2hac 0Tt3euBuc44CjG06KZZrkL7wPWfU0YPFVtakX2pi5wBATUUVNHrsW3npswjDBQm+nZS+ Lk/tCL+2zhIbD1JEOTG3cndrXFGicuDYc1nL/rytPFZ1RCjh8n2995UsN/lEhumHP/fy +7u50GP+m4aBlC94V44zgimVxGmPv5ZN9zpHd0rjhNtWmfFthLoMUAhdrZ2112FQR41q I4uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682012183; x=1684604183; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z2JgYL8DkZMdzf2YexeAn4MdqBHMsfy9XvbP/7e9/AQ=; b=YEXNEldBhkwnYhCS/s/Ut3Fvxqh4mUGq8hL4RcKNQkl8NKtk4HcLm1Zs2k3BEMyvva 8fc6pdArhvhUjHsl+7mO+lh0PGigdEwT2Czc3xlzjsayAqGDA0wdB4C3XhXeO49aZzyu /AUJ3tJAat5jhcgpliJaQBS+K2JG8E5Z9zTMqOkeV/1KZFhfgdZliNjcTLqHI9NDFxfm gYzayB5JgqkJYRyENEd1ZKdo/tbrIg/Ngzaw9UwKAo4hHrE6xqK3KECdPzGj/Fuc8vXN njpCGMxKoB2HhOMzKge9AAJ58d1tmapwlaLnsEZpS7W2gAx5dY4igVA4jsp9yF4AL4Bq xUKg== X-Gm-Message-State: AAQBX9cdrxrQZKekTlCouOJ+nkcfL94mvJubZPeDJ426BrCGYxYd7H80 JL6E67AyPOBjg6CDHtxXmWd0Og== X-Received: by 2002:a05:6512:487:b0:4ee:d6dd:c2ac with SMTP id v7-20020a056512048700b004eed6ddc2acmr746078lfq.22.1682012182936; Thu, 20 Apr 2023 10:36:22 -0700 (PDT) Received: from [192.168.1.101] (abyj144.neoplus.adsl.tpnet.pl. [83.9.29.144]) by smtp.gmail.com with ESMTPSA id l16-20020ac25550000000b004edc16dbdfasm281336lfk.119.2023.04.20.10.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 10:36:22 -0700 (PDT) From: Konrad Dybcio Date: Thu, 20 Apr 2023 19:36:18 +0200 Subject: [PATCH v6 2/2] soc: qcom: Introduce RPM master stats driver MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v6-2-2277b4433748@linaro.org> References: <20230405-topic-master_stats-v6-0-2277b4433748@linaro.org> In-Reply-To: <20230405-topic-master_stats-v6-0-2277b4433748@linaro.org> To: Andy Gross , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Dybcio , Manivannan Sadhasivam , Manivannan Sadhasivam X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1682012179; l=7425; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=IadQaWvw/PAWvPdWixiSC+ek19eqmbHpl0ewiFD0fMM=; b=gQtQkziaCviipQpLtICCupbveRpe0ELO7t4mneRIY6AyqGpHIFWyhv/buaJTHam89lJfRXrwPjPg tBt4f2BsBQWx8TpekmY1b5nuJjup+2L5wYxb+0AvgHFWF1Oj4RYX X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763717760359472008?= X-GMAIL-MSGID: =?utf-8?q?1763717760359472008?= Introduce a driver to query and expose detailed, per-subsystem (as opposed to the existing qcom_stats driver which exposes SoC-wide data) about low power mode states of a given RPM master. That includes the APSS (ARM), MPSS (modem) and other remote cores, depending on the platform configuration. This is a vastly cleaned up and restructured version of a similar driver found in msm-5.4. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Konrad Dybcio --- drivers/soc/qcom/Kconfig | 11 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 163 ++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index a491718f8064..e597799e8121 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -135,6 +135,17 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPM_MASTER_STATS + tristate "Qualcomm RPM Master stats" + depends on ARCH_QCOM || COMPILE_TEST + help + The RPM Master sleep stats driver provides detailed per-subsystem + sleep/wake data, read from the RPM message RAM. It can be used to + assess whether all the low-power modes available are entered as + expected or to check which part of the SoC prevents it from sleeping. + + Say y here if you intend to debug or monitor platform sleep. + config QCOM_RPMH tristate "Qualcomm RPM-Hardened (RPMH) Communication" depends on ARCH_QCOM || COMPILE_TEST diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index 0f43a88b4894..7349371fdea1 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o qmi_helpers-y += qmi_encdec.o qmi_interface.o obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o +obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o qcom_rpmh-y += rpmh-rsc.o qcom_rpmh-y += rpmh.o diff --git a/drivers/soc/qcom/rpm_master_stats.c b/drivers/soc/qcom/rpm_master_stats.c new file mode 100644 index 000000000000..6dd98b9f7129 --- /dev/null +++ b/drivers/soc/qcom/rpm_master_stats.c @@ -0,0 +1,163 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2023, Linaro Limited + * + * This driver supports what is known as "Master Stats v2" in Qualcomm + * downstream kernel terms, which seems to be the only version which has + * ever shipped, all the way from 2013 to 2023. + */ + +#include +#include +#include +#include +#include +#include + +struct master_stats_data { + void __iomem *base; + const char *label; +}; + +struct rpm_master_stats { + u32 active_cores; + u32 num_shutdowns; + u64 shutdown_req; + u64 wakeup_idx; + u64 bringup_req; + u64 bringup_ack; + u32 wakeup_reason; /* 0 = "rude wakeup", 1 = scheduled wakeup */ + u32 last_sleep_trans_dur; + u32 last_wake_trans_dur; + + /* Per-subsystem (*not necessarily* SoC-wide) XO shutdown stats */ + u32 xo_count; + u64 xo_last_enter; + u64 last_exit; + u64 xo_total_dur; +} __packed; + +static int master_stats_show(struct seq_file *s, void *unused) +{ + struct master_stats_data *data = s->private; + struct rpm_master_stats stat; + + memcpy_fromio(&stat, data->base, sizeof(stat)); + + seq_printf(s, "%s:\n", data->label); + + seq_printf(s, "\tLast shutdown @ %llu\n", stat.shutdown_req); + seq_printf(s, "\tLast bringup req @ %llu\n", stat.bringup_req); + seq_printf(s, "\tLast bringup ack @ %llu\n", stat.bringup_ack); + seq_printf(s, "\tLast wakeup idx: %llu\n", stat.wakeup_idx); + seq_printf(s, "\tLast XO shutdown enter @ %llu\n", stat.xo_last_enter); + seq_printf(s, "\tLast XO shutdown exit @ %llu\n", stat.last_exit); + seq_printf(s, "\tXO total duration: %llu\n", stat.xo_total_dur); + seq_printf(s, "\tLast sleep transition duration: %u\n", stat.last_sleep_trans_dur); + seq_printf(s, "\tLast wake transition duration: %u\n", stat.last_wake_trans_dur); + seq_printf(s, "\tXO shutdown count: %u\n", stat.xo_count); + seq_printf(s, "\tWakeup reason: 0x%x\n", stat.wakeup_reason); + seq_printf(s, "\tShutdown count: %u\n", stat.num_shutdowns); + seq_printf(s, "\tActive cores bitmask: 0x%x\n", stat.active_cores); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(master_stats); + +static int master_stats_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct master_stats_data *data; + struct device_node *msgram_np; + struct dentry *dent, *root; + struct resource res; + int count, i, ret; + + count = of_property_count_strings(dev->of_node, "qcom,master-names"); + if (count < 0) + return count; + + data = devm_kzalloc(dev, count * sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + root = debugfs_create_dir("qcom_rpm_master_stats", NULL); + platform_set_drvdata(pdev, root); + + for (i = 0; i < count; i++) { + msgram_np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", i); + if (!msgram_np) { + debugfs_remove_recursive(root); + return dev_err_probe(dev, -ENODEV, + "Couldn't parse MSG RAM phandle idx %d", i); + } + + /* + * Purposefully skip devm_platform helpers as we're using a + * shared resource. + */ + ret = of_address_to_resource(msgram_np, 0, &res); + of_node_put(msgram_np); + if (ret < 0) { + debugfs_remove_recursive(root); + return ret; + } + + data[i].base = devm_ioremap(dev, res.start, resource_size(&res)); + if (IS_ERR(data[i].base)) { + debugfs_remove_recursive(root); + return dev_err_probe(dev, -EINVAL, + "Could not map the MSG RAM slice idx %d!\n", i); + } + + ret = of_property_read_string_index(dev->of_node, "qcom,master-names", i, + &data[i].label); + if (ret < 0) { + debugfs_remove_recursive(root); + return dev_err_probe(dev, ret, + "Could not read name idx %d!\n", i); + } + + /* + * Generally it's not advised to fail on debugfs errors, but this + * driver's only job is exposing data therein. + */ + dent = debugfs_create_file(data[i].label, 0444, root, + &data[i], &master_stats_fops); + if (IS_ERR(dent)) { + debugfs_remove_recursive(root); + return dev_err_probe(dev, PTR_ERR(dent), + "Failed to create debugfs file %s!\n", data[i].label); + } + } + + device_set_pm_not_required(dev); + + return 0; +} + +static void master_stats_remove(struct platform_device *pdev) +{ + struct dentry *root = platform_get_drvdata(pdev); + + debugfs_remove_recursive(root); +} + +static const struct of_device_id rpm_master_table[] = { + { .compatible = "qcom,rpm-master-stats" }, + { }, +}; + +static struct platform_driver master_stats_driver = { + .probe = master_stats_probe, + .remove_new = master_stats_remove, + .driver = { + .name = "qcom_rpm_master_stats", + .of_match_table = rpm_master_table, + }, +}; +module_platform_driver(master_stats_driver); + +MODULE_DESCRIPTION("Qualcomm RPM Master Statistics driver"); +MODULE_LICENSE("GPL");