From patchwork Wed Apr 5 15:01:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 79760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp390165vqo; Wed, 5 Apr 2023 08:22:42 -0700 (PDT) X-Google-Smtp-Source: AKy350b8pSgiJIDr6+LtraGRALMYn5IH9bH0zICvFXdVwnGn9/QMXBIvV3br0UmKRDMrqcRW55fb X-Received: by 2002:a17:903:28cc:b0:19a:b869:f2f8 with SMTP id kv12-20020a17090328cc00b0019ab869f2f8mr6379246plb.21.1680708162593; Wed, 05 Apr 2023 08:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680708162; cv=none; d=google.com; s=arc-20160816; b=ZyRnA0iJBvZ3P6t/yqYoXJQ7k7Z/NJD8LFOd+vygQGkn6QbmTQjxS3O0qYz3vmLVgL OzvCn+HqSVKJzSlnRuuvQ5F2Z0T9nzNFCj+to0Yc5G00UClA2TcF18EVfu3BXBbKxpZ3 a5wz+ZSwFexT2mISQLgmDaP85UspDrCs4ikKCF/VlcUtsi236+3JgfPJhfo6RbptJZtj tgN2fy2W/s9VkACxDNijdORBRE4OJhAKzkrLc57RdouvbWaz6ExXuTWWz7OoU/xtF3Wc wevr4bFx/tZb9QLLwGeMz1qMe54LU5OVaPPYS5KZ6yVHesZLeysshVsCkA7AdwgWExik D/JQ== 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=W6Ju8CIEzaK87pEwl0n+uObDKxQlL1nqcBRnevkvACM=; b=oo9z3+kSbcDeRjXVvfK1KFs/UNQJhfYLNm4wz1BO1W2EnOJ0bBTdDF5IuyN6vsRj8/ Ix84YH8HMM/NLIKrzDAqPwCvMcpzTJy6R66401CKagbXTAuB4UnBfsCbgqaXKYX3Xu7m y+/J3emudz4u1E2SRymzq/oVBkw5vQ77+urCzsNfZ2JL/Beq3/fOjLUAJS7HsUiCTp+w t4N7r37ZyNvizP1HmpJ5oagoPrUn9bQTFnql7ch955qdBovuC+uOInJnUt+uLTFGn1T2 kZQd47untlIf86tG893LXsYQhsJVY0LCGbT+zehBkWiWq2QDl96ElU1PrNZ7p38qMyeE 38mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uHp/SrAj"; 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 bv129-20020a632e87000000b00508b8b16db3si12144188pgb.656.2023.04.05.08.22.26; Wed, 05 Apr 2023 08:22:42 -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="uHp/SrAj"; 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 S238548AbjDEPBu (ORCPT + 99 others); Wed, 5 Apr 2023 11:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238433AbjDEPBq (ORCPT ); Wed, 5 Apr 2023 11:01:46 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC595259 for ; Wed, 5 Apr 2023 08:01:43 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id g19so33917427lfr.9 for ; Wed, 05 Apr 2023 08:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680706901; 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=W6Ju8CIEzaK87pEwl0n+uObDKxQlL1nqcBRnevkvACM=; b=uHp/SrAjB5GGfZSeT+l/3+ThUPUu3B/tMP0PlBveDZHPHNEJWpcnOnvUTsfokgXHvZ X1Vb98woe/BIBj8nlp7rpSGeomPfpdgHBoqeiBBcLmex6ZgXi08MvUBJl/9nsChJ6cs9 7iv9F85ItKQx7AP8qJkPa5hAEWANaY/IIs46wvZcg2SdBdoBTOcTzEntuDNhDtxNmZ/9 3tpDZakhfUfXC9vKE2QmeJFu0tyMU6/UsQx8E8gUYqDJfBtB1YcjRZrLm7h/YhB09nZi 6fROQkxje+KbNI9ytKTHvSBLKakIY+SrkzfQqbiPAHMcY2sOxZKc+BMq32N7SBrcEpLI CItg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680706901; 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=W6Ju8CIEzaK87pEwl0n+uObDKxQlL1nqcBRnevkvACM=; b=SIdIT/rI9UXFxONWkowwNkjTsAyjtJkSzJiNq8jH14f2X3Bn3KR2lReLef5NHSwrwK +OgEndW7J9p7gAqANtjPdj/eb30QPcpo68o8RSqLywABgHA44Kd3WmofCv0Lof3w11el Yn5CC/kzY8KCKt1OQyo2VQ9NY0ht83ujyX78fCuhtKodLNffxZnkjKqcOXZi6HoQUoXM B8CaM+NEQa7MQFkAIDMqiA8qO1nmlUAW57lwLU2KHpEefjBiIeijWz1dksrhfaQlukPn ZDTtePCotwsYmNqnV62iUsK2F2mJnAfdqwZWRtcWzXLtLU7M1gEStYJ6CB8vhs6CYCk6 GPsQ== X-Gm-Message-State: AAQBX9exYJgmLNvkHnAuhJDC+XCCLbFe5QbU7F0Lt8jEkg+0XWskBX4j v0vIU1g/FH1fSDyE/DBW2/nXAQ== X-Received: by 2002:ac2:43db:0:b0:4cb:4374:cc78 with SMTP id u27-20020ac243db000000b004cb4374cc78mr1825915lfl.26.1680706901595; Wed, 05 Apr 2023 08:01:41 -0700 (PDT) Received: from [192.168.1.101] (abxh37.neoplus.adsl.tpnet.pl. [83.9.1.37]) by smtp.gmail.com with ESMTPSA id 16-20020ac25690000000b004e84896253asm2833994lfr.251.2023.04.05.08.01.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:01:41 -0700 (PDT) From: Konrad Dybcio Date: Wed, 05 Apr 2023 17:01:35 +0200 Subject: [PATCH 1/2] dt-bindings: soc: qcom: Add RPM Master stats MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v1-1-1b1fa2739953@linaro.org> References: <20230405-topic-master_stats-v1-0-1b1fa2739953@linaro.org> In-Reply-To: <20230405-topic-master_stats-v1-0-1b1fa2739953@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=1680706899; l=2156; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=pOnWKQ9D5V1MjOyO4kKJpCciYdrkhMQtlWjnxKSUZfQ=; b=kgxETiISULWaSx50jp87qTXp6E9fgC29ravRA/S3GQbrjwlyxn37Hl8hhyYJffco835ubl/035zo o6vZrtGmAjlrRXgy2U4TnUyqjvt//XxEvqlDAN1x793Uyp1UgsSp X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1762350242295536431?= X-GMAIL-MSGID: =?utf-8?q?1762350242295536431?= 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/rpm-master-stats.yaml | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/rpm-master-stats.yaml b/Documentation/devicetree/bindings/soc/qcom/rpm-master-stats.yaml new file mode 100644 index 000000000000..e8e71e75d161 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/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/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 Wed Apr 5 15:01:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 79745 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp377037vqo; Wed, 5 Apr 2023 08:06:39 -0700 (PDT) X-Google-Smtp-Source: AKy350ahCe1hx7PRLw+FNMyOQO99ec0LIj5qzg/RVBzt+CopLO5vdWMonz04uWTP65/YMGJJY2o1 X-Received: by 2002:a05:6a20:3820:b0:d5:7f0b:f2f with SMTP id p32-20020a056a20382000b000d57f0b0f2fmr5411049pzf.26.1680707199538; Wed, 05 Apr 2023 08:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680707199; cv=none; d=google.com; s=arc-20160816; b=vG427JxcfJz591CBFOlHbEB4FpcV2BwXqb8+I9Ho5KAVAg0XZIuEZ+DSYbjOq5od1V 5SMWM7yi1PwRWTceaLSwiSbUYwD00EqvVNCDICrTUB5R8dmL6iJ1kR1prLDzYLkCdIJa gjKilZHGyKbA/mtCgpJOi0qU1swaGPimZu9UluZE+qLygAuZctLk0TZCtmRgg1gcu7EL HYZQdUfCmyHT9Ab3uOefXP0CGtxJQZ57dvk5EMinCMGtoKOY0UoD1W3CN4l78eB6udMj lBm54tRkp7AdkOqnQTIINU9SBCetvmdoeL/Ohh4jZKJLP+WnkEjvOD4ihzfmk5C+NxGq 95gA== 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=Enslf/wirWR/vFKVajt29WdovTFd9sBu4HdJK5iLVV8=; b=pTYAAWhEWARlPQ9Av+4hsOZ/bI5xETDRojl73r9otAzXugL1U+qO1lF55TSYQ55LTz XxzRfFRUwYJ1FkgjdRqpIffIPiQKQXtt3ZbsQne9WHDP7GZ0QR+Nc9XHxuZb84hA+epX ONU/G8bd3eWJKi+dZTE4bSMzZ/X8RRIq6cZqAQXWLIsw6SbT2tVPXCeyc9c170LQbn/Y ZPq9BvlfQQKGDbicerDVLudqnqLHdmSWv0myw6+gHCW8dA+mYLF0HRngl7GwLruYq4R0 JPpwR6biK1A0zuyjZWAyM8YZGa9pM+O760pjpNpLSFkE1+t/gLQi77RqPbgkbeqmw0cn wTSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZLKpkDYJ; 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 e8-20020aa79808000000b00623b50eb7d0si12363996pfl.214.2023.04.05.08.06.24; Wed, 05 Apr 2023 08:06:39 -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=ZLKpkDYJ; 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 S238489AbjDEPBx (ORCPT + 99 others); Wed, 5 Apr 2023 11:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238509AbjDEPBs (ORCPT ); Wed, 5 Apr 2023 11:01:48 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD3E4EE9 for ; Wed, 5 Apr 2023 08:01:44 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id k37so47090706lfv.0 for ; Wed, 05 Apr 2023 08:01:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680706903; 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=Enslf/wirWR/vFKVajt29WdovTFd9sBu4HdJK5iLVV8=; b=ZLKpkDYJBL1i3E5zK9vhu3Ry2Tog6qgOhFAv/eFFG+3ZWjzoUGVQgG4U2KdsbjzdJR Ul7w35P2cLihFz8D3hE50IJadFTSfhbDB3rDdcZlri8wtuCk8vJlxWnLGE06jZkGDHZW GgjARyDs0E8MaLfx0QL2dR/oqOUlIi3mmNh3RbgK9XoYmluTVdNTNCPSmSTqBodrrxyi tayLC75wtGMDIdAh8HnIw8QE9yVHCyEZjWe+oGRU1X+Qjph/qjzFYI35dwRjmDPXor+3 YLiFhhTYNlgG8gJVczs+agBQLVYtw0XuR2KZP+HAwGYjyposZxsgbwbMlPG/x9WymW72 sCAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680706903; 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=Enslf/wirWR/vFKVajt29WdovTFd9sBu4HdJK5iLVV8=; b=dq0Gn1rgwOZG0hzprxoIprWl3+1rTXeTWI8X0QetnZSlRVS14EZZ3anpJXyNhNo+pr KNg2YLF3jxEw5BbhfY0B4WcoIRXmbOKCfWbTzRMFZZ+Iu2EwVJ5VCcklP7A32FXglVPi MqkvutkMXoKecxO0ac7cC0xyPjGJTnmf69qQTP0sBRCfrfUly4qgX9UByAH/W70ZFGmi iLGyOUFYjkXv4wftwLDoB7u2G527309ljNZxz8NzQHG+12bPtQF/oJWheS9sffyJo0XW TILYDHNp/7oH11PryCwfMaNrvzbUiEN/StZ/ImD0Lr5ZYjpa0j3KR18SuY+CAXoMSINA KJjQ== X-Gm-Message-State: AAQBX9eGCCR8UP+u6USo59/agm2kHCe8XOz2nqCAFeJyy2poCZ6Pq9xU WDm5YJ9VK76DyiUgrF2xWHxHow== X-Received: by 2002:ac2:5111:0:b0:4de:f972:6aa with SMTP id q17-20020ac25111000000b004def97206aamr1694910lfb.4.1680706903094; Wed, 05 Apr 2023 08:01:43 -0700 (PDT) Received: from [192.168.1.101] (abxh37.neoplus.adsl.tpnet.pl. [83.9.1.37]) by smtp.gmail.com with ESMTPSA id 16-20020ac25690000000b004e84896253asm2833994lfr.251.2023.04.05.08.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:01:42 -0700 (PDT) From: Konrad Dybcio Date: Wed, 05 Apr 2023 17:01:36 +0200 Subject: [PATCH 2/2] soc: qcom: Introduce RPM master stats driver MIME-Version: 1.0 Message-Id: <20230405-topic-master_stats-v1-2-1b1fa2739953@linaro.org> References: <20230405-topic-master_stats-v1-0-1b1fa2739953@linaro.org> In-Reply-To: <20230405-topic-master_stats-v1-0-1b1fa2739953@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=1680706899; l=7204; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=UojBg6OM/XiZOOjQEvx052TRoaZQuzw+LM43xt276lg=; b=O7MAzoUHuFf4/U/KwYy3sM0ib5EvM8BsD4dzoO09CF0JNsrcOlt1mmu19Ugaayf4MVmuTkscpeRn zhsgQfVCBR6Z3C4M6sgfmCL9OC55Yq7+Sxi5xdmFA1llCFaiBdF/ X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1762349232629205845?= X-GMAIL-MSGID: =?utf-8?q?1762349232629205845?= 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 a25df9e3c70e..325b733c102c 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 6e88da899f60..196bb87f2576 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..759bfa1e01c4 --- /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 %s", 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");