From patchwork Mon Apr 17 17:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 84376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2296737vqo; Mon, 17 Apr 2023 10:46:15 -0700 (PDT) X-Google-Smtp-Source: AKy350bLb7DqtXCxCEm30wuQ/yTYDKzuHqsZh5FI8oXjDrfUYZDJR90OVeus5EXeucgyxrbjfDhq X-Received: by 2002:a17:902:d54f:b0:1a6:6c79:9d42 with SMTP id z15-20020a170902d54f00b001a66c799d42mr14462073plf.30.1681753574931; Mon, 17 Apr 2023 10:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681753574; cv=none; d=google.com; s=arc-20160816; b=q18RdidDIvmHRI1SvrmoUC/ozgBtwlEOtC/Tj7R4ACKpl5LUDjs6EI+WFUGeDe572w nidpDOELx3iFWQ/seJvgXLjYrIDyWFg4vcWFhbCbEVzwjqXWj1pkIC3flclRuxUaO6O2 L8wIsumnh2lcLQhiq3lOEbp+xidhtxFI+emy53ML+rNIPZUtSHu+/lLN69uTOTBPyHSb jt7YidcAut61bDEIhn8KqEWpTh4vJt3bjiut74+semVqhHUbYW+JmF44HBcO7rtRkJbS bARY5mT4U07/n2Bxu/IsTTsNUhiiRJY099aAkJglNg3CLGdVEB7/59DFZcBrqS1wPO9L cw4g== 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=C5D6a8r2vjcLnAgtEKEffI+VrzgTR4nUIJcaNud3nvU=; b=tffTwV4iyirOt0Cm98q4IcdwazqKNtkcG74XxjtohKk9oxh6UfpRl6zeQQqKLcc20P 3bTrILzxFdgefKVVSQ0X6VipcJW4C/Z4in377ayn7pnT1rTgNqn1V61sK4AFdY2hTM3I 2FiDrwHhUguLu8zToiZoV0Q0IuAcOwcC0OD21f87hrOXrs7OTBl1PBfJLfhKy4jFs0Bt 6ysd4oigXxoJegKrhklBkApTLv10caoTvBJ34MCQW7ejJoMK/JEYLFJvNkL7mMEJ6NFl 5eNwDMpWUz040mzGtRHFODTFAG5jRkziS8J2ckO6Wwan49++7qj/fcdxa0Q/x+pVOaQu 1v/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i2y7sA+e; 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 u14-20020a170903124e00b001a1c8afd0e4si12739116plh.635.2023.04.17.10.46.01; Mon, 17 Apr 2023 10:46:14 -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=i2y7sA+e; 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 S229915AbjDQRiB (ORCPT + 99 others); Mon, 17 Apr 2023 13:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbjDQRh6 (ORCPT ); Mon, 17 Apr 2023 13:37:58 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE0974218 for ; Mon, 17 Apr 2023 10:37:56 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id x34so13863172ljq.1 for ; Mon, 17 Apr 2023 10:37:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681753075; x=1684345075; 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=C5D6a8r2vjcLnAgtEKEffI+VrzgTR4nUIJcaNud3nvU=; b=i2y7sA+e2AtfVmI0/a/icI4GjhAi8a09xMJWMpjdA+b7DUhrpZwSodiezPPSt9DkeP ebIcFstiJu/JyhWOhvE7i1mxgUtIGezRPfJtdxWS4CPc+X7VmI3cnLGDqI4gBPfGmSLd hDj5OElHR69FseLlXB04zzTO9zSa5WoDkECv1vgqQD0/ywmMVaW/RaNlIoAGvVbxRsN2 7mm1F6/Vgdegl40GLipEv+tNWHLhoNJ4zfAuqj/06+gEwn+xGgXTSVRKinF07fhZAMHh kvj9HrSeAsFQ9whcqPBIHDMpGRRPrnFBmXNZRtrs33y52iYlt4xobSe58yUEQVHJUHk+ DgWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681753075; x=1684345075; 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=C5D6a8r2vjcLnAgtEKEffI+VrzgTR4nUIJcaNud3nvU=; b=SkiYrAKP6laAlpz+6+eBEMdT9oZqYnKPKOcXoXT0YTYqt46pr/GtnmqdUbVGUtRO3F 1YekmtglRpGPOxKblE6IZCoY7So9qcu0S0pU0MGvzdyu1JvjhhXAhttq5erkheHoLam0 H6+wUA2zeCz+Re8ZmBAaoAouc4rPPCIx6LssUArzzaldWPtT7XtjITVOK9Ks/HchFkIt GQoWwiMVDeqWqTJ01iR5XwBXBI8H4sEpr8l/5abVtz0o7FkrLhELveb1WC9pflslTqDO 9qPy10OZkD0smycGLM0MhLk52vpX31X2fzlxjm8hemX3hSFl9KGyE1aIiihGICwBmQnY 4t5Q== X-Gm-Message-State: AAQBX9eNMFqCgum3nQThHX3QxdsKUEUgu9Se+hI9MEVfRJ3eqS22VEoZ 328U8x/Pac6/BHXdawVrx/YpSQ== X-Received: by 2002:a2e:8758:0:b0:2a7:71ef:f89 with SMTP id q24-20020a2e8758000000b002a771ef0f89mr4269708ljj.15.1681753074985; Mon, 17 Apr 2023 10:37:54 -0700 (PDT) Received: from [192.168.1.101] (abyk99.neoplus.adsl.tpnet.pl. [83.9.30.99]) by smtp.gmail.com with ESMTPSA id h13-20020a2e900d000000b002987088bda4sm2191329ljg.69.2023.04.17.10.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:37:54 -0700 (PDT) From: Konrad Dybcio Date: Mon, 17 Apr 2023 19:37:52 +0200 Subject: [PATCH v4 1/2] dt-bindings: soc: qcom: Add RPM Master stats MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v4-1-4217362fcc79@linaro.org> References: <20230405-topic-master_stats-v4-0-4217362fcc79@linaro.org> In-Reply-To: <20230405-topic-master_stats-v4-0-4217362fcc79@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 X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681753072; l=3175; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=xF/pWuxUJ8x72O6U8YUe4JAHlOtuPuhzk2ELuhhwxdk=; b=Dvdm0IRU+WFG0mCrHoNch34vBJnaHxhh6Y8K2CbAuI3yBLBG4dNE4vNgEyjIoyZJq4JcRYH3tWT/ IDlUkKA5DDK/qajP8WtRKbh1CzKRybPu5I6/IY6m5G+ppXe29bmB 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?1763446436387459132?= X-GMAIL-MSGID: =?utf-8?q?1763446436387459132?= 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 Reviewed-by: Krzysztof Kozlowski --- .../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..8a654979ce92 --- /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 decisons + (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 Mon Apr 17 17:37:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 84367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2293554vqo; Mon, 17 Apr 2023 10:40:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bzLAsQ+PEXIkahv0aMdOWfVXvXKkwEYvGJQdhhaOA5zjUTenYaJPulrv9IvqMuvQ6kT7Ep X-Received: by 2002:a17:90b:1e04:b0:247:9450:eb6d with SMTP id pg4-20020a17090b1e0400b002479450eb6dmr4043853pjb.49.1681753206265; Mon, 17 Apr 2023 10:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681753206; cv=none; d=google.com; s=arc-20160816; b=WDZ2PJEoT47HXYsQkt8S4iSXMjiw6+T91uy2QDNfReVLa78a4BgH8MMCSALzrwZ+Yi AsLm3VMr/zWKJ7BdgJWtYBVKr9vWfTq46J9Gu04uS0FFORmo0tMnUaAjbuEsdRq6iNBd jM+VWjElp7I1o6hVpQvMWDcwKMNie9xoRZrcKgzg1vJIdJt/4+PDr7k0m/1thIMI6e7t 2WhJmQu3MrAdrh6QuCp8ByTmi4Bwepb9PZBfKEZytaIJ69ZJoF6tdSdbAA3j86cDNI4C SNNsEmxlJ9eLftxHyl2FNFVsxFSQKVrYoSYPcIiC4CxwpCfqZLoaYnPeVXxFXANzRvuc +L5g== 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=uuOGCY0YC27DnDSyEpTKjfXfgDWLpz/eBDtA/u84pMU=; b=Wg0XEbBusZ5r6mHz052Gjq+0kHZNvgQLUqllX7TR5WDpBBWUaThFQLbemwUSy8DyHL Kb3L6yMAhXN86cfL/Y8sxneXFF90pKvp5FvKnzD8kIdltCaiE3ozzQs8xccItabyoRyA aJ2bN55AM2D11vE5xrUEx8+KOlrL7MqqFJIwgdkwaEOnU0Htnpsw2rE9n5dI+C2OiZyQ MPp2zbRmJtWsTYoo0yfYSMaI+zPNWIITnIE33R2K0ZOKoMnO6YnrwrKKXf6XxsqW5G/g BM65RB5g3PACaczjN5TdaLLz/rI+gdBLjgUvlS/+nD0CuZoydO6d+Ae3sKO7SFCMk9Ib q7fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yzl5jrvh; 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 k63-20020a638442000000b0051b5c9dd1fdsi11682301pgd.685.2023.04.17.10.39.51; Mon, 17 Apr 2023 10:40:06 -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=yzl5jrvh; 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 S230369AbjDQRiF (ORCPT + 99 others); Mon, 17 Apr 2023 13:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbjDQRh7 (ORCPT ); Mon, 17 Apr 2023 13:37:59 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03F71BD1 for ; Mon, 17 Apr 2023 10:37:57 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id j11so14956339ljq.10 for ; Mon, 17 Apr 2023 10:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681753076; x=1684345076; 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=uuOGCY0YC27DnDSyEpTKjfXfgDWLpz/eBDtA/u84pMU=; b=yzl5jrvhIWzjI5pWkNMEb78CStV/WJwKO5wgtOCKGW4MnV+w5xXofB4GKNlsxYPKhD byz8Bkog8atqwEJn09jcdrFzy1Y9RhsFn21YG5m8tuT4UNJLI6RQGR2edtSXQTyAbrif Ty+vWK/ClVhIBfwltFay+BztvmZ8jUC8Ww9/jsCUSIqsL+xt0CDAnGGDxmCzTw6Qxdjh gitlKKurBNMyrUmloPyk3oFzi3bi3q8Jh1u6mmMVaNsLpnjlN8Hy7muIEu2OKKQxOoLH ipboH1ckCosIk+pYs2m0x24hyntjbEYrys53mkPmZDO7oCKl3YS/Wf+PQ58REUbs0VFB 4x1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681753076; x=1684345076; 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=uuOGCY0YC27DnDSyEpTKjfXfgDWLpz/eBDtA/u84pMU=; b=CGmtrB7lepixoWwlxCdPDUXsRyPSQuO4Lf2mhcigg8JP7hqJ2t9XbfZvzDyXUAyQRQ OYu+gOETXud9qAEEp5y5+lL/AktHEJBn4Joz2YDj1yOAMoZ77r/PLfZu0atVGLLa34nU z6BYSboJUmIt3uqyy8zs4zCoBvvxOboD6yVMQkOiwTNUjCG+aXoLq0Jhlno6kGIToOK1 RCmVMCQjq4DLEq1QCDtVbXCkvxLMJ+eWvBmW8WQofUZ6mFBcceJ1csTq10eIIlWIvRBc tRYwyhnim6siqL+oCsbhpa0p2ddQjd0Wne/vkW8kf7XlD16cvmudSpDQYaeW1vNfbJ+a MX6Q== X-Gm-Message-State: AAQBX9eCaIwOXRS19PrwPKdAeJbii/HYUw7FgffKFKvnkfnC8UtpOIAz oa4SJzF2tToX8CL81b7rrjiLDg== X-Received: by 2002:a2e:9349:0:b0:2a8:b168:981f with SMTP id m9-20020a2e9349000000b002a8b168981fmr2508926ljh.46.1681753076185; Mon, 17 Apr 2023 10:37:56 -0700 (PDT) Received: from [192.168.1.101] (abyk99.neoplus.adsl.tpnet.pl. [83.9.30.99]) by smtp.gmail.com with ESMTPSA id h13-20020a2e900d000000b002987088bda4sm2191329ljg.69.2023.04.17.10.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 10:37:55 -0700 (PDT) From: Konrad Dybcio Date: Mon, 17 Apr 2023 19:37:53 +0200 Subject: [PATCH v4 2/2] soc: qcom: Introduce RPM master stats driver MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v4-2-4217362fcc79@linaro.org> References: <20230405-topic-master_stats-v4-0-4217362fcc79@linaro.org> In-Reply-To: <20230405-topic-master_stats-v4-0-4217362fcc79@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 X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1681753072; l=7339; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=8gsn6U4CGo0S02zD/8MmPyM/NPVm8x4jX2vbho9jzHY=; b=ukvLi+DqJJTWvKsUbVpWpUxASYB/Vc19tPEfA7DmavN+Kvqi8D1LRWFzfD/beFnK0N76/gg5U0gy 8Pb5hZRTBwH5cUuhN/sJTYx3buJwFR7crTOJVa2M5OKKioLYsCRm 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?1763446049671357880?= X-GMAIL-MSGID: =?utf-8?q?1763446049671357880?= 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 | 162 ++++++++++++++++++++++++++++++++++++ 3 files changed, 174 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..ac87401e2217 --- /dev/null +++ b/drivers/soc/qcom/rpm_master_stats.c @@ -0,0 +1,162 @@ +// 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 { + 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; +} __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 -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("Qualcomm RPM Master Statistics driver"); +MODULE_LICENSE("GPL");