From patchwork Fri Apr 14 11:37: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: 83376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp333672vqo; Fri, 14 Apr 2023 05:14:29 -0700 (PDT) X-Google-Smtp-Source: AKy350b3GQbb20ixIgSw8aDRb3OC5bSo97+C+1leTbksZ/NlCg0+J21mn79h3mPS4WPvJBt+oUiI X-Received: by 2002:a05:6871:79c:b0:184:8300:bfac with SMTP id o28-20020a056871079c00b001848300bfacmr3863244oap.35.1681474469081; Fri, 14 Apr 2023 05:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681474469; cv=none; d=google.com; s=arc-20160816; b=xCgOl6bQnGqq30KU7+aivELc4WHIcotqBVBw35eGZcgrnE6+BzjiC62RqNV1kBEtQo +aIEAToW4y18abNwSfKEoxMu3MSQ/fTajwk8cxIWpfV2I6DzqSirrTdhLRfFmA2/rAO7 b/8B1++1eogNY2D3mb+osBlWRzxo3UMPSrClfRnI9iWigN3+wYEYpH8yrJLUEotc1JD8 xOYc1YP4oSs8CZ6JVCMAmHfxT4V6qKD3t8TBeFwzIEDSnfTGGcEwlnSxfJ96ZaGelqp/ P6XyxjRfBu+UEv1ktE7bcl0TCLPdi5pTZdANQpZB8GK+rlh99GBmXHVZB9Uz736I4UjY Gsbg== 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=pjBdsofLs3+4G8st7nvJWY7fIQpctrGr3PE8MEm6BzQ=; b=sZ31MhF8dro3ReCJlm/Ol4bATZhada4Kn3QDoa1qW0UFhOJ+Inz6sHSjxsqWzXo+xu w5+8CB/q68roW6UwE+IlEvztuW624B6yqXI45v2MY/j2Vd+k/wMbjxhiUnC2oonoWqnx hpu+eRWaUpzK1GGbjONcTI4XrsES9JXc8lCNkwrbSEV2+xK2UfZ6GIh4amW3sxfZkDcw ghQtz6bVBM9wBaWUlTeF0rzOGSiny3VE3VLG0LcPgEtdB6VRxKaK5elD8onhvw7clf4W Wrq6YKD9WBcPvpA5XjsFuHsxk519Eqd2Hst0HL56sSDMnMYeWPdCJga4NYnY/tv/2QtU a2ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hzBrlhIv; 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 q22-20020a056830019600b006a1495d16a1si4065058ota.356.2023.04.14.05.14.16; Fri, 14 Apr 2023 05:14:29 -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=hzBrlhIv; 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 S230257AbjDNLh3 (ORCPT + 99 others); Fri, 14 Apr 2023 07:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230152AbjDNLhY (ORCPT ); Fri, 14 Apr 2023 07:37:24 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A1A27D81 for ; Fri, 14 Apr 2023 04:37:22 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id b40so2505562lfv.4 for ; Fri, 14 Apr 2023 04:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681472241; x=1684064241; 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=pjBdsofLs3+4G8st7nvJWY7fIQpctrGr3PE8MEm6BzQ=; b=hzBrlhIvvN0RTsEhtWNx+QObaZS+HtMR7hvASL5X7M4Cka95Zh5IcSJ9AHEeqWuTbe gahQC08KkM7RGtu2FyPu7TZ4/XJLl6+ts3mraEf2g9mqKvavi2z46+eRA7LG/N8T+ByF 41uiuEFyGE4bNjJyHXfhDOBJOe1DZWbpYzNU/+0aoopz0KpwplaUi3dwqcGst/Js8/cy uVPM9GToWGAiElnqsuQtjY3o+Bgbc7qB4R/5fsODUttHg2WrduNW5+6XZGzEJG32a3WN bskJFl6oIsh9sh6MCnEJPmA1dbJToIIvmuQXv/JaCG7wZCKGI5ewvQLygaI9CKq8L6Lt XBpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681472241; x=1684064241; 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=pjBdsofLs3+4G8st7nvJWY7fIQpctrGr3PE8MEm6BzQ=; b=fafgQChxzYZDYd5u08eZ/lQNYA6QIsfqJ5ucFrrwROfRh94E+QrDIVbiqViSiBJt9Z CxqPKyCCKgiXl1dsQwY2s8YNfMwTQ3Ctzyphz6fOc+lmK0r9HLcu8tlg15eN7lXEaz70 0cNxZw1Vldws8WcgJBjAWhGzr5yTJH6WpXoBp1Fx1h8vrim3dsQ3mr6nIPeojTdL3Nan aQAnHlJZnQumggDhCEhzQEMubg6BUt2BpGkTjqAFy+sRkGiV9Zs+q7fFuO1t1mcnPccZ 3uExUlPgvrxt5D5p0Xwh6HljzhlOnbFtCPdRFVTgF8+yNFIu/+Uy1cLULZlDViMcP4LR jeVg== X-Gm-Message-State: AAQBX9dyTSB5gYMYzqo/OtJUkE2bqVIWXUqvMXrFxlueL+/bLB8JxnUE OEd8cTCP9OwxHFhyUGTu6Zr3Lw== X-Received: by 2002:a05:6512:511:b0:4eb:4160:7ca9 with SMTP id o17-20020a056512051100b004eb41607ca9mr1500868lfb.16.1681472240817; Fri, 14 Apr 2023 04:37:20 -0700 (PDT) Received: from [192.168.1.101] (abyl123.neoplus.adsl.tpnet.pl. [83.9.31.123]) by smtp.gmail.com with ESMTPSA id y5-20020ac24e65000000b004ec83bc3e43sm756946lfs.192.2023.04.14.04.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 04:37:20 -0700 (PDT) From: Konrad Dybcio Date: Fri, 14 Apr 2023 13:37:17 +0200 Subject: [PATCH v3 1/2] dt-bindings: soc: qcom: Add RPM Master stats MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v3-1-2cb2ba4f2092@linaro.org> References: <20230405-topic-master_stats-v3-0-2cb2ba4f2092@linaro.org> In-Reply-To: <20230405-topic-master_stats-v3-0-2cb2ba4f2092@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 X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681472238; l=2174; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=TH1zgnCa8zRbU3KMG+EVZMt/V85Or/9zrfIZNwaDzLA=; b=P45AxPiiNgpI9Zd/uzJUdSIwikCqiN0AsWEGmaeP0EgoKO/c4S8+MZiWRWa8DXYOruEbYAFvNtT5 cM+ZFzqOBJNDIeUrg17h1Su9k8HVu9S1lnBNSncGlZSV9zxlPY/t 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763153773164284796?= X-GMAIL-MSGID: =?utf-8?q?1763153773164284796?= 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. Signed-off-by: Konrad Dybcio --- .../bindings/soc/qcom/qcom,rpm-master-stats.yaml | 53 ++++++++++++++++++++++ 1 file changed, 53 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..d7e58cbd3344 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,rpm-master-stats.yaml @@ -0,0 +1,53 @@ +# 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: + Per-RPM-Master (e.g. APSS, ADSP, etc.) sleep statistics. + +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: RPM Master name + 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 Fri Apr 14 11:37: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: 83375 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp322794vqo; Fri, 14 Apr 2023 05:00:08 -0700 (PDT) X-Google-Smtp-Source: AKy350Znhm/jW7rYZiZmyGbkFbALbqjdEsspCY/RU4MgGgkyNoYTr4U9lJwu49YTjU1yjsDmJN0t X-Received: by 2002:a17:902:e845:b0:1a1:ab92:5c88 with SMTP id t5-20020a170902e84500b001a1ab925c88mr3182523plg.13.1681473607902; Fri, 14 Apr 2023 05:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681473607; cv=none; d=google.com; s=arc-20160816; b=czcHOlVhr5qr4bnicj6kOBSf4VIYfhmcZrqoISL25aaxHrgUrAMcfY7vurLBF4tbH6 rBn8330T0mlaKxyLIhfbHcqVPJmoj5pZ7w9WLgYnxR63g3je+DqCdaVRWLw9lOSYTFu+ 5mRZGP+hVap7kpa2N190artUXINSfaNx98x2PRjATYAYphnYxqDVbkwywpOXu6dZ/Vkp sGu1Hjc6hzQZp2PoEdtvDRleCW0WqCoK6zWf0JqM34gcpGjWkOV6WrRMP9e+ucprCCOy I1O7N3dLLxqBa0KeUF9QvMbXqz/F+nz+eCwDPNW+YY8JFvUool7umTgdrc3FDsAqrLSV dZdg== 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=ISD1jIsYhapCYWWcz+5k3pAzTGPESmv5s/eS+sFm/Hg=; b=ZWK6kc+zIaSuaIOa/Qpgxo6UiseEpj0k59InrfKqfvCnheiO5QCRcjAstenQAKp1u+ Ndf6Yg/zRW+HvwtwF5QHy0WLBd1yYruAWV21b8PBuHdOLFwysmgHojiqr6sCgKbNsxAD TS8j7/2MkFRIsefDgrZlgBme+xbey3cmQBoFBmjueqlmK5GATK+2JFrzjfqFFMQhXtfz kt7PqNP8BNpjmImjw1No/wd+Plp9DHvNfP8QluCj8JPjA6xxRee43iIYteB2LRpQwRmJ Q1UCJdVhybdhmjpWij/7XeRuq3Ds40v3uNVaJOeVZ199mSsP+6ZyhPu7pl20Wxq2LVgZ c9uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yn+a8wJ8; 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 e18-20020a17090301d200b001a534e0e863si4889544plh.63.2023.04.14.04.59.52; Fri, 14 Apr 2023 05:00:07 -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=Yn+a8wJ8; 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 S229704AbjDNLhc (ORCPT + 99 others); Fri, 14 Apr 2023 07:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230382AbjDNLh0 (ORCPT ); Fri, 14 Apr 2023 07:37:26 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 903B276B3 for ; Fri, 14 Apr 2023 04:37:23 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id x4so3071067lfr.8 for ; Fri, 14 Apr 2023 04:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681472242; x=1684064242; 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=ISD1jIsYhapCYWWcz+5k3pAzTGPESmv5s/eS+sFm/Hg=; b=Yn+a8wJ8gv1qZmhb+z/wE+fuvt/rcYbb8kz7kfkqSXFgHRc0BgsLC0q8O4NMiEzR7o pKgUHRdqp+8IGGPNH8Ywgbf7DWpaI8ggAiibJFFIlaU5cRR3j2I5xbUHFtjDuKFTfzB5 s20M5Ut1nHBArSCleX9AuBS07MaGJQLckXs9R7D9DCULQPN6sAA8bHp6l4OVgDRDZweH eF3XGQrwpxNgEttPBBrGAOfAz799scOk9U/AwVvXdDISPWBzr/sD2GGpfu+p04B7QpZO eMQz3qifremBL3yejGU5B8aznbnJfAJ6+73aEobu+dzwNvYZup+v1f92XXdyonajb/jH YCbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681472242; x=1684064242; 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=ISD1jIsYhapCYWWcz+5k3pAzTGPESmv5s/eS+sFm/Hg=; b=lC4XksvbhxJbZUIyTM70YBYvXW+c/sP6P64ukHXTK8iIJ774Eeq+DOGPFllKRCl0yv VesrMq+eUk8BWaFJtV58Q/ydi0aRR1LoWH8RUREiQZBaKITX8zYrf3hfK8/tyh9MXD0G MNy5cCE+37h6gvn0ZFZqzokqHRcbK9sqCwSdRF5VVoGdVsRFs6yUZ1o3BndoCDYNCpET 9680fUei3Dq0/zmXdWAjtE5SL49td+wmhw/2Xup8tZwEA8WpZO6NR27XSNf0oJV80U/V 9Sh7A72FQmRueBCBvHvMeXYxaeHuB2FPvREdyW9epI7qEUWrUPVb3POed3gCcl5TtQgR HBog== X-Gm-Message-State: AAQBX9fts+3BjS1pVipT2eGmW5awYM5oPHwI8SFcQFgwfRKrQ0utJSqk Mjqh7vMeDoqe3PF565Qx/84xMH6ttU0ohiI4oiE= X-Received: by 2002:a05:6512:75:b0:4db:3927:e2bc with SMTP id i21-20020a056512007500b004db3927e2bcmr2007693lfo.50.1681472241922; Fri, 14 Apr 2023 04:37:21 -0700 (PDT) Received: from [192.168.1.101] (abyl123.neoplus.adsl.tpnet.pl. [83.9.31.123]) by smtp.gmail.com with ESMTPSA id y5-20020ac24e65000000b004ec83bc3e43sm756946lfs.192.2023.04.14.04.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 04:37:21 -0700 (PDT) From: Konrad Dybcio Date: Fri, 14 Apr 2023 13:37:18 +0200 Subject: [PATCH v3 2/2] soc: qcom: Introduce RPM master stats driver MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v3-2-2cb2ba4f2092@linaro.org> References: <20230405-topic-master_stats-v3-0-2cb2ba4f2092@linaro.org> In-Reply-To: <20230405-topic-master_stats-v3-0-2cb2ba4f2092@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 X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681472238; l=7204; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=hb0oyhgLV35bIH5MUQG7WNpjMFfzdLIJfQqifL30BjY=; b=uUDbYx+s7nKX8/aLuRZUv8bje+vhs+kkDvgeYYX6mxdcN+8NbMTdggTUm4S/k97zgE+Axldis6gL v5e7WnwNCxuthqP7wyPeR2H40Gi5wss157ApgLKUCPoR6ijpz3GU 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?1763152869660208675?= X-GMAIL-MSGID: =?utf-8?q?1763152869660208675?= 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. Signed-off-by: Konrad Dybcio --- drivers/soc/qcom/Kconfig | 11 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpm_master_stats.c | 160 ++++++++++++++++++++++++++++++++++++ 3 files changed, 172 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..73080c92bf89 --- /dev/null +++ b/drivers/soc/qcom/rpm_master_stats.c @@ -0,0 +1,160 @@ +// 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", 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 { + uint32_t active_cores; + uint32_t num_shutdowns; + uint64_t shutdown_req; + uint64_t wakeup_idx; + uint64_t bringup_req; + uint64_t bringup_ack; + uint32_t wakeup_reason; /* 0 = "rude wakeup", 1 = scheduled wakeup */ + uint32_t last_sleep_trans_dur; + uint32_t last_wake_trans_dur; + + /* Per-subsystem (*not necessarily* SoC-wide) XO shutdown stats */ + uint32_t xo_count; + uint64_t xo_last_enter; + uint64_t last_exit; + uint64_t xo_total_dur; +}; + +static int master_stats_show(struct seq_file *s, void *unused) +{ + struct master_stats_data *d = s->private; + struct rpm_master_stats stat; + + memcpy_fromio(&stat, d->base, sizeof(stat)); + + seq_printf(s, "%s:\n", d->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 device_node *msgram_np; + struct master_stats_data *d; + 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; + + d = devm_kzalloc(dev, count * sizeof(*d), GFP_KERNEL); + if (!d) + return -ENOMEM; + + root = debugfs_create_dir("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, -EINVAL, + "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); + if (ret < 0) { + debugfs_remove_recursive(root); + return ret; + } + + d[i].base = devm_ioremap(dev, res.start, resource_size(&res)); + if (IS_ERR(d[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, + &d[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(d[i].label, 0444, root, + &d[i], &master_stats_fops); + if (!dent) { + debugfs_remove_recursive(root); + return -EINVAL; + } + } + + 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 = "rpm_master_stats", + .of_match_table = rpm_master_table, + }, +}; +module_platform_driver(master_stats_driver); + +MODULE_DESCRIPTION("RPM Master Statistics driver"); +MODULE_LICENSE("GPL");