From patchwork Tue Oct 18 15:28:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2020418wrs; Tue, 18 Oct 2022 08:29:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7j6aAMA1l5+12ujGv5S/eQ4ipfeUCQ+knM4p1qAg3ea/SYAmrJi1GQ5uXc9dym20nZ3zRc X-Received: by 2002:aa7:c0cf:0:b0:45c:6a06:ea9a with SMTP id j15-20020aa7c0cf000000b0045c6a06ea9amr3124669edp.211.1666106992380; Tue, 18 Oct 2022 08:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666106992; cv=none; d=google.com; s=arc-20160816; b=xwU0b+kCK/H1IZUzBMxTSFU3Ii7en6jKuqKYJyYtFtGTL6q2NhCnmvDo2r2gtBq17k ryIBTtBqdJ9Yp8tT73hS1i6d8mjHKMSpIyxSyt4ouCcFjArBiJJNNgumWHHF9xr8Puho 5k8RnvcKys0tMCRuevpIo+ago91v9jIXxC3lyL1APeknrY76qv/dW5qFcp1hlxcYVR7/ Am+PxiTxko+4NgDJcC+YaLW/mdQAJG+iDPhPNfaMqs4Ph1t/QKVvKW/uMkA8GEObVWXm E8UZfG+zvHu5/FWfjbCOdHu71llcUA8wzafL2GLQ44MPY9T83gLxLfk7dwueF8xSGSCQ Nucw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S/dijha3PtsBLc1oCRl1z/7+SdFNWj+DBXw7ruAqJvs=; b=Ht+G5g9ASF7Xsxb1kzjitSjNSZ2DtXtuJ1+LNq9bAP69WhZmVL7hIltyjwOipk8byH AEVnPrahM0FlmYui85F6zXP+L+q5/66wZ4hRXZMNY+RISL10JtRqkUVbJ8YQFKvyGsem GdX9HTT+14/wprU7hEQkcOWurrxnC6SYOhiH9bMXfQyCU0X06bIpRCVfjGt8RO2VEZkn wWGmY8DrFhE2c67xVzNaarFLqfELnCoF3wVLCRcRrRA7IA22GXsulwuOyHAyCScIw6VJ KRahre59E3cnG7z6/MXLpKaUUyBIV1Mq6AINW+VIsQ0ZjwDqEZS5dvni5TMQ9bSrDENV Ysgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSikYmYm; 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 g11-20020a170906520b00b0078334ccc570si10930293ejm.328.2022.10.18.08.29.25; Tue, 18 Oct 2022 08:29:52 -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=rSikYmYm; 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 S230318AbiJRP3J (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbiJRP3C (ORCPT ); Tue, 18 Oct 2022 11:29:02 -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 77165D2586 for ; Tue, 18 Oct 2022 08:28:57 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id bp15so23140177lfb.13 for ; Tue, 18 Oct 2022 08:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S/dijha3PtsBLc1oCRl1z/7+SdFNWj+DBXw7ruAqJvs=; b=rSikYmYm+8u2z+yR9sPDioiSvgcn6vlTeUZ7O6VuQRte7vTuBGlzmfUcgMMTyUb26B m+PAAjrbsIm3GQcm4PyUAsH+fn9xVCLeHI2QKkwFE921vgKbKi1W4NG30l20x3Sminab nuZ9nH5Q3WJJBGy25ClaFIzeG8J17DmgpUVib5MX+EdDLolgDdz4zXGRQVwkMFuqkBIg 7+yCazZ7paoEsPgTg0SlsH7SofOvqyj4F92uRLsTnQytTIjMamIeI3sggTHCwKscuD6u /zkgnewkF+slZZGIG7dGLv1zU8EdTLdJpbZyGzk6g/DPvt85nr3qj7pMF5ThIu5TJN8y /WEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S/dijha3PtsBLc1oCRl1z/7+SdFNWj+DBXw7ruAqJvs=; b=UltJPe9YY2EOgnsvcgO8lWH1v9rtaZBRZFJvKgs0mEyuOTHT6WitPS3y9YMvIaTJjc uvk4DLgk2iWrrE+2ZzCMnOsgNLKVNi4+eXS+qtR7835+oZZ1Qkfo1Kiqv7IzIAz28A5/ duagUX0N0J1tZATYlg0eKcK+ggOfOJ0KcS6bC5cJl8v+SJj5wzvZOpwtOvNFS1u2Mj7J 4bIWxfWd2dBQwhOGMzPElOGwmd9biOX1PksZeG0/w+zgUQo2Ff9s11/e9fW78H24IXWM wXkMuBQHAQj3B8u2WLHSI8IeBgxvYx6iPj/crJ1hxERLkzlvjhCaW9K2dzgMONUR18Hq tHMw== X-Gm-Message-State: ACrzQf0IFZe8dRc8LiKmkHHuTEXqep3EHCteHqOXjEIv6oUklW6+MGEG z7KFOq0VLM/ABUO4PNcGUt2UEw== X-Received: by 2002:ac2:520b:0:b0:4a2:26d2:be31 with SMTP id a11-20020ac2520b000000b004a226d2be31mr1283316lfl.473.1666106935831; Tue, 18 Oct 2022 08:28:55 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:28:55 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Herring Subject: [PATCH v3 1/6] dt-bindings: soc: qcom: Update devicetree binding document for rpmh-rsc Date: Tue, 18 Oct 2022 17:28:32 +0200 Message-Id: <20221018152837.619426-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039805798938671?= X-GMAIL-MSGID: =?utf-8?q?1747039805798938671?= From: Maulik Shah The change documents power-domains property for RSC device. This optional property points to corresponding PM domain node. Signed-off-by: Maulik Shah Acked-by: Rob Herring Reviewed-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- .../devicetree/bindings/soc/qcom/qcom,rpmh-rsc.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,rpmh-rsc.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,rpmh-rsc.yaml index 4a50f1d27724..b246500d3d5d 100644 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,rpmh-rsc.yaml +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,rpmh-rsc.yaml @@ -99,6 +99,9 @@ properties: - const: drv-2 - const: drv-3 + power-domains: + maxItems: 1 + bcm-voter: $ref: /schemas/interconnect/qcom,bcm-voter.yaml# @@ -151,6 +154,7 @@ examples: , , ; + power-domains = <&CLUSTER_PD>; }; - | @@ -197,6 +201,7 @@ examples: , , ; + power-domains = <&CLUSTER_PD>; clock-controller { compatible = "qcom,sm8350-rpmh-clk"; From patchwork Tue Oct 18 15:28:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4222 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2021572wrs; Tue, 18 Oct 2022 08:32:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yIzFAOx49Nn0RMLXDKKOodgobx2dNqH6FDb9CtsNu1fnj1tAAh2Fgq0Xd8mpqe8d5otgH X-Received: by 2002:a17:907:7ba4:b0:78e:281d:91ef with SMTP id ne36-20020a1709077ba400b0078e281d91efmr2941639ejc.288.1666107131788; Tue, 18 Oct 2022 08:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666107131; cv=none; d=google.com; s=arc-20160816; b=aKF5RSL1QeCPG1nGH/B/8x7zNmHKQGsYE0EA7d621+jf+1yLi9F/NRDx8eiP+4AxiO 9x4P7H2jWyjG2vVghhrcaWTvbBciaMC3/wqgzUZOlk8y4gZmzKbaD5BvZRA0Pbri1VyF v2Vs4G6j6XfB9TeZR26muHa/fpnbaYMV3+q5pbjHorwfix+3dCz1JDnAS+jK0yjuCARI bM9IZbsqfAIgNVIob5a5Jig15oXQer6Myc1Jf4QsP8nCZ4NbApOf6mMiB7SIPi3+JXFm 0COqsIEK/CiY8+hl+nZJUD4IIzeHkcdRX4IEfgbvI+MS08b6/bYMKiZrTF6+33dPyuRO EKog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A/0uCXFANsoh0DiFy9dIOdQIaRdJECgtgeqYv4vuwUA=; b=fp1oFvDfesOOPSqypQgGHmKHrlwP5Hcft4mp4ESVUKtO7e2ocnlPJzP2RYlv+jirgB v2+tFfhWNBQ1d71B7o6hUEkNJ3hOBQ7K7Bad3pbO7MIJKgmTkqygOwzYCWwKKG47YN+Y b4ADJkdUeQWF0KoG6HAm2olM0bqCYfG0gzP/fmyRXw74jlPDRoXdZvHanXl8yigIdrx3 4fU4zC8m+ukEBTWa/WT3nemQwFIsA6RHa4KCXBdZ8E6jLMPp4ILUPGyeCUOErzQ7hrz0 fSHAG7s/1VD24oZS0v2kiSDE/7a/aacpj/HnFSpUseg2ZmJMInXQgxE5e4RfHHr86wui Yj7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vNt+110Y; 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 q12-20020aa7da8c000000b0045934c32fbasi10428689eds.171.2022.10.18.08.31.44; Tue, 18 Oct 2022 08:32:10 -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=vNt+110Y; 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 S230346AbiJRP3S (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbiJRP3E (ORCPT ); Tue, 18 Oct 2022 11:29:04 -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 577CDD2CC5 for ; Tue, 18 Oct 2022 08:28:59 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id bu25so23198867lfb.3 for ; Tue, 18 Oct 2022 08:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A/0uCXFANsoh0DiFy9dIOdQIaRdJECgtgeqYv4vuwUA=; b=vNt+110Y7Gze3Oupa9oWy7MGrfPQGa+VRB7raEBf7jWSRnlAfXjtRi5QANEZt/HWCr CVQ9bZtQfmtqUYetmVfyt/Vc1Pfy5aXhAChdOxO/jeuLongT0CdZytmGEHexof7ANQqe 5U1yCBzVnTE2jlY9AL+k1gXKBnfl1+QnPynXEJmEpAJJdCuLVZEKsrLQAc/4WD4SNrGl w3y/MKx1arEHDu0YkHuN5j6kJsICoxxz1k7HXX5iuaAuZT2YnRTPvAFSLUKvPdzzmMLf Sa/qInkeJkBcFJQtJYpSsK4pQlImVBwB9WMmP40hJHwAkr+lATznD0LSEVvGlYDwH1dg lPsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A/0uCXFANsoh0DiFy9dIOdQIaRdJECgtgeqYv4vuwUA=; b=2ak//Of1nuOTClrAXdmG9jGEzp0ieMhmmTnCZmRNxrc9g7G7JMsMPyResT5ER5LXGB i8GsgIlNIr7J5/xONyqfD8O9+VnI0BHTFbZ6gJK3htH4tlDRx+47fMCovRLw7/pi/6+9 SrHav5agAp78zd0EK/bW36cAr6wCEscxOM2xH8+hngjp5kE/lpssCzym3ixZaZQiZlu9 YA2KKDe07Gawt9PuKnlpKP5kxU/2CjYPacwd1lwMjKDoXrtc4O/9xuDlnhXRoH+Ig5iJ R6cYzF0Da1nOUHrg3nGIp7sBbZxTHvfauBA6U9tJZeBQetdVzv+WXVhv7Ws2lO+4P1Xy V/zg== X-Gm-Message-State: ACrzQf3zhCwXplpRveu63Yq/75oSccGVubI5vpF8dObkdsxxeZxIiVBM v/XEZM7OMUe6GnUEfQF5YpEBEg== X-Received: by 2002:ac2:4dab:0:b0:4a2:7344:3d65 with SMTP id h11-20020ac24dab000000b004a273443d65mr1255244lfe.315.1666106937599; Tue, 18 Oct 2022 08:28:57 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:28:56 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lina Iyer Subject: [PATCH v3 2/6] soc: qcom: rpmh-rsc: Attach RSC to cluster PM domain Date: Tue, 18 Oct 2022 17:28:33 +0200 Message-Id: <20221018152837.619426-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039951454205787?= X-GMAIL-MSGID: =?utf-8?q?1747039951454205787?= From: Lina Iyer RSC is part the CPU subsystem and powers off the CPU domains when all the CPUs and no RPMH transactions are pending from any of the drivers. The RSC needs to flush the 'sleep' and 'wake' votes that are critical for saving power when all the CPUs are in idle. Let's make RSC part of the CPU PM domains, by attaching it to the cluster power domain. Registering for PM domain notifications, RSC driver can be notified that the last CPU is powering down. When the last CPU is powering down the domain, let's flush the 'sleep' and 'wake' votes that are stored in the data buffers into the hardware and also write next wakeup in CONTROL_TCS. Signed-off-by: Lina Iyer Signed-off-by: Maulik Shah Reviewed-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- drivers/soc/qcom/rpmh-internal.h | 4 +- drivers/soc/qcom/rpmh-rsc.c | 67 ++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 344ba687c13b..cd3d6ce137e3 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -97,7 +97,8 @@ struct rpmh_ctrlr { * @rsc_pm: CPU PM notifier for controller. * Used when solver mode is not present. * @cpus_in_pm: Number of CPUs not in idle power collapse. - * Used when solver mode is not present. + * Used when solver mode and "power-domains" is not present. + * @genpd_nb: PM Domain notifier for cluster genpd notifications. * @tcs: TCS groups. * @tcs_in_use: S/W state of the TCS; only set for ACTIVE_ONLY * transfers, but might show a sleep/wake TCS in use if @@ -117,6 +118,7 @@ struct rsc_drv { int id; int num_tcs; struct notifier_block rsc_pm; + struct notifier_block genpd_nb; atomic_t cpus_in_pm; struct tcs_group tcs[TCS_TYPE_NR]; DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 01c2f50cb97e..050b5f5c9f62 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -14,10 +14,13 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -834,6 +837,50 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb, return ret; } +/** + * rpmh_rsc_pd_callback() - Check if any of the AMCs are busy. + * @nfb: Pointer to the genpd notifier block in struct rsc_drv. + * @action: GENPD_NOTIFY_PRE_OFF, GENPD_NOTIFY_OFF, GENPD_NOTIFY_PRE_ON or GENPD_NOTIFY_ON. + * @v: Unused + * + * This function is given to dev_pm_genpd_add_notifier() so we can be informed + * about when cluster-pd is going down. When cluster go down we know no more active + * transfers will be started so we write sleep/wake sets. This function gets + * called from cpuidle code paths and also at system suspend time. + * + * If AMCs are not busy then writes cached sleep and wake messages to TCSes. + * The firmware then takes care of triggering them when entering deepest low power modes. + * + * Return: + * * NOTIFY_OK - success + * * NOTIFY_BAD - failure + */ +static int rpmh_rsc_pd_callback(struct notifier_block *nfb, + unsigned long action, void *v) +{ + struct rsc_drv *drv = container_of(nfb, struct rsc_drv, genpd_nb); + + /* We don't need to lock as genpd on/off are serialized */ + if ((action == GENPD_NOTIFY_PRE_OFF) && + (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client))) + return NOTIFY_BAD; + + return NOTIFY_OK; +} + +static int rpmh_rsc_pd_attach(struct rsc_drv *drv, struct device *dev) +{ + int ret; + + pm_runtime_enable(dev); + drv->genpd_nb.notifier_call = rpmh_rsc_pd_callback; + ret = dev_pm_genpd_add_notifier(dev, &drv->genpd_nb); + if (ret) + pm_runtime_disable(dev); + + return ret; +} + static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv, void __iomem *base) { @@ -963,7 +1010,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev) return ret; /* - * CPU PM notification are not required for controllers that support + * CPU PM/genpd notification are not required for controllers that support * 'HW solver' mode where they can be in autonomous mode executing low * power mode to power down. */ @@ -971,8 +1018,14 @@ static int rpmh_rsc_probe(struct platform_device *pdev) solver_config &= DRV_HW_SOLVER_MASK << DRV_HW_SOLVER_SHIFT; solver_config = solver_config >> DRV_HW_SOLVER_SHIFT; if (!solver_config) { - drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; - cpu_pm_register_notifier(&drv->rsc_pm); + if (pdev->dev.pm_domain) { + ret = rpmh_rsc_pd_attach(drv, &pdev->dev); + if (ret) + return ret; + } else { + drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; + cpu_pm_register_notifier(&drv->rsc_pm); + } } /* Enable the active TCS to send requests immediately */ @@ -985,7 +1038,13 @@ static int rpmh_rsc_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, drv); - return devm_of_platform_populate(&pdev->dev); + ret = devm_of_platform_populate(&pdev->dev); + if (ret && pdev->dev.pm_domain) { + dev_pm_genpd_remove_notifier(&pdev->dev); + pm_runtime_disable(&pdev->dev); + } + + return ret; } static const struct of_device_id rpmh_drv_match[] = { From patchwork Tue Oct 18 15:28:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2021609wrs; Tue, 18 Oct 2022 08:32:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ABzYqNd09rPjZ4tY8ewIwgeM2IDWFhKyagVqvQhbHuqRc4KlATatttl3BSiQGKNFLGsaB X-Received: by 2002:a17:906:eecb:b0:73c:5bcb:8eb3 with SMTP id wu11-20020a170906eecb00b0073c5bcb8eb3mr2861255ejb.284.1666107134980; Tue, 18 Oct 2022 08:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666107134; cv=none; d=google.com; s=arc-20160816; b=ll2Tzif8LvUPuzRgXEz94PbpUkMwzzCWTxYnwgWdRb0Kw/OOKgEpgdWIM1cEiXgxKf 7L2ZJwCUZ/s+Ev55P3eeN0DiUG5REC86JnOmLx2v+6ZrARsjnZlVhx/s1lcbVTQeW4Dk pNg9MeqDVVYVrmxgH67M/HhM1SEAbOTU3qdKEj5tgXx0dZfQPTId2WC/ZXxkzPe+ywSX XgaPhPxu1YwbDGCSPgL+SUUfKVauUa51zvWrHl2bNM5uikrLrVY28CqI3GLKJ44aD58x 3KTnryJ+8bz2dAEMxBt2Dis1X3oonL/hqo8Cz523t0IFMQgkhdaZuD5zjPJ4xQrYKu9a 2FPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AB4pG/wpKwLSAILs9IcGtC4gbTwQNljlapP0erz1+Bs=; b=YAAxBRFY7bXKdgQjYCituLOjDYfiuc6Rgc5o120WiCo7xB3lSFBeNRmjfYOZdwYOHt jh2bYcfEK+xQ8T/N6eL2q5l5pE5Yy8Ej5FnFfcteJ5cFnxqTJZdbutNPSLvwV+vftDXT M6fyInCgQYQYw/oPsCg4UtPZD/8Mqvfa3M+3gB4PXXpmFHWHslPoafBVcRWqwzqrk5+x wIM8VFgff84bbazhal/hrcHELyuH2B7k3nItOrkQAfmITjph9ZpKxn6YGfyoOKX39LDE bc4tuRFl18RYMMU5YPAm5BwuN33J9OaAwxWl8+mq9jWNSVfbhgXRxCz/JxaTUe32FOBP 0hIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ry/gKAX/"; 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 z2-20020a1709063ac200b0078e1708513esi8575139ejd.824.2022.10.18.08.31.49; Tue, 18 Oct 2022 08:32: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="Ry/gKAX/"; 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 S230425AbiJRP3Z (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbiJRP3E (ORCPT ); Tue, 18 Oct 2022 11:29:04 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 434D3D01AF for ; Tue, 18 Oct 2022 08:29:01 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id bs14so18394196ljb.9 for ; Tue, 18 Oct 2022 08:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AB4pG/wpKwLSAILs9IcGtC4gbTwQNljlapP0erz1+Bs=; b=Ry/gKAX/ngx4cgGV/cyifxKrzZCaj65Gv0gXz7a8QKD7E4wJqsZG19WRsiriUYP1RN l343f1RyO9LQJmTATviNmsoVpm2p1znDRGoV32NysoAJi4t8n+oslv+8OJpzAiCEsk82 iVhGVVgiFIdDbathwWj0cQHgRL/NzlpTFTjCF4xSwuCn/HwhwblbykfUKsXHRy9WurFm dguFAsbuZGZwkIwMDHaDKGqXmeIFdTLWGTbGlMJnim26FJ642syYC2xGwyacHO7//L27 PR2qqkPYsM49HieuEdksYdEUvSK6Q/po4+OHHpgtuchRQqU9jSomo3BBVjHfz0wuZnvG 8oZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AB4pG/wpKwLSAILs9IcGtC4gbTwQNljlapP0erz1+Bs=; b=hzf6aZ//Mja7OB6wsbG2MWKCK3Vew3pmJntlzHqzzgfV4eqlSEp9AyNMDJ/tSgNDCl wfJDxHPBHQG3v2Nsry6utF3YRkBvlNgbxnr1xrsUOhmZOr23JtKxEJU99Afct8kTd/Yw 7ZoPUEDyJoUpidFVM8Bp4F2WLTMk3GmShLiGxa0vys5i1mpBHQW2PrcVXk/ZJWoT5wu+ clJ3xPpzPpAQFdxu3WupTG4oszsgB/QtOkGlTy1ANenWNdVGheQZ4DSgFsdb4oxSW+Xv aedbvTZ/1uHWGtwS5Yupj0WwIWGz0YBsZBYJFQrvSV8JxTSDtxwHAtDGZjxfEqR6tFa0 RCXw== X-Gm-Message-State: ACrzQf2L8AYVyv3RLWRftdzSN+oXtfTlRSxH3jK+SQ07MiDp4zVcj3sI ocCjwWPXHmKE9ceysN5ACzC4zw== X-Received: by 2002:a2e:bd0c:0:b0:26d:d9fd:f61b with SMTP id n12-20020a2ebd0c000000b0026dd9fdf61bmr1299091ljq.151.1666106939451; Tue, 18 Oct 2022 08:28:59 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:28:58 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/6] arm64: dts: qcom: Add power-domains property for apps_rsc Date: Tue, 18 Oct 2022 17:28:34 +0200 Message-Id: <20221018152837.619426-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039954961043407?= X-GMAIL-MSGID: =?utf-8?q?1747039954961043407?= From: Maulik Shah Add power-domains property which allows apps_rsc device to attach to cluster power domain on sm8150, sm8250, sm8350 and sm8450. Signed-off-by: Maulik Shah Reviewed-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- arch/arm64/boot/dts/qcom/sm8150.dtsi | 1 + arch/arm64/boot/dts/qcom/sm8250.dtsi | 1 + arch/arm64/boot/dts/qcom/sm8350.dtsi | 1 + arch/arm64/boot/dts/qcom/sm8450.dtsi | 1 + 4 files changed, 4 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8150.dtsi b/arch/arm64/boot/dts/qcom/sm8150.dtsi index cef8c4f4f0ff..ecaae6f5ee6b 100644 --- a/arch/arm64/boot/dts/qcom/sm8150.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8150.dtsi @@ -4010,6 +4010,7 @@ apps_rsc: rsc@18200000 { , , ; + power-domains = <&CLUSTER_PD>; rpmhcc: clock-controller { compatible = "qcom,sm8150-rpmh-clk"; diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi index a5b62cadb129..c32227ea40f9 100644 --- a/arch/arm64/boot/dts/qcom/sm8250.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi @@ -4955,6 +4955,7 @@ apps_rsc: rsc@18200000 { qcom,drv-id = <2>; qcom,tcs-config = , , , ; + power-domains = <&CLUSTER_PD>; rpmhcc: clock-controller { compatible = "qcom,sm8250-rpmh-clk"; diff --git a/arch/arm64/boot/dts/qcom/sm8350.dtsi b/arch/arm64/boot/dts/qcom/sm8350.dtsi index a86d9ea93b9d..b5d036d72059 100644 --- a/arch/arm64/boot/dts/qcom/sm8350.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8350.dtsi @@ -2004,6 +2004,7 @@ apps_rsc: rsc@18200000 { qcom,drv-id = <2>; qcom,tcs-config = , , , ; + power-domains = <&CLUSTER_PD>; rpmhcc: clock-controller { compatible = "qcom,sm8350-rpmh-clk"; diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi index d32f08df743d..d32dcb042778 100644 --- a/arch/arm64/boot/dts/qcom/sm8450.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi @@ -2999,6 +2999,7 @@ apps_rsc: rsc@17a00000 { qcom,drv-id = <2>; qcom,tcs-config = , , , ; + power-domains = <&CLUSTER_PD>; apps_bcm_voter: bcm-voter { compatible = "qcom,bcm-voter"; From patchwork Tue Oct 18 15:28:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4220 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2020545wrs; Tue, 18 Oct 2022 08:30:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4juTmAjRALHLT2Er3c/+KKgOwB5A7at87ViI5qRoXyQJdzkNOk1kxJWWnzJljxqjOj8yn2 X-Received: by 2002:a05:6402:2744:b0:45c:9978:eae8 with SMTP id z4-20020a056402274400b0045c9978eae8mr3173100edd.361.1666107007603; Tue, 18 Oct 2022 08:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666107007; cv=none; d=google.com; s=arc-20160816; b=cPI/9uIejhfWotsBeBdikJb0+KgLsk4BWzAiqulMrSmryrtUzmcM2MVNV7KjoM2IlM v+YBZpNI/04X0Ojgy7QGvwk17JfMT7tXHREgHk8ATgH2jm+jvWioGQ3V/4HZWBLQDg69 c+BypBLFrnA7rHV5dLUk/omsH0TTGyoCVX/hhUuLPnmdxzl7NKjXBbW3Ioyr5LYixqCt 28AX9z2BgHGCtioJpuSYDXlUpT6fC006BzGoINLK291droFKEP66QUG7zZ6zy7e0MyBn Ap4WapoafiWOaMtRilg5GePJDzeRfrz9aPosgNYva3dQTzHpV0vG4JCtz2RTNLmwnFt9 Cqsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YIHoKtHeSXxO4LyumWrPFFvJIZDXMTgh9sxej2UY0h8=; b=WKbDYETnZbU+YcqjLA/+XGBZZNNoldWmImPkqU+SgPBGVyM5SS9xzIjgW4s8pp+cd1 lK+spgQaBiwElX9+CXFRZH4Bt8GZ6gMFzqy9NyBt+AROrxDogWBCbrIaWiScY3mL3y4v UE5s/04YuiBy9aOkWSq+b3lsqY2SkgdOW1iL26lTFK20p6fKFOayLxYbBMd3/5Ta4pv1 ii2jTSWAR12ei1iyCtxcuD/alZEzNGI0eHW3/hYdeSY1GZ8v6wUVvP4T9P09Z/P5tJl3 v38Hqyox2fKRs9jULxegnvK3QnbfIlnYG31XrLtrBf8NvIuFE2wiEucoEVKQGxOBXI4v QIdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ulojaKy3; 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 v17-20020aa7d9d1000000b0045879feb9fcsi10619307eds.185.2022.10.18.08.29.38; Tue, 18 Oct 2022 08:30: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=ulojaKy3; 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 S229827AbiJRP3M (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbiJRP3F (ORCPT ); Tue, 18 Oct 2022 11:29:05 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21D4EBC470 for ; Tue, 18 Oct 2022 08:29:03 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id bs14so18394309ljb.9 for ; Tue, 18 Oct 2022 08:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YIHoKtHeSXxO4LyumWrPFFvJIZDXMTgh9sxej2UY0h8=; b=ulojaKy3M1drjBcgrb1mzDHoG+uItWDuJtCaHGJjQ6TIdrtO+ld+au0G1cRkuqshxX ocsXpsvyJB1HI1dOxz8sbq8W13zZY1n5/ZKBgmug5nYHYKrFsqERMFqGNRJSqTsvWKHv TKXVGDmwApwYIeOIk1Hagu15w2TEGrCLxqKkhHazm5nlj6uKamdNFnrsWwO/jQVe1lPz 7INPAf1g80y9Kct8CCgGDukNh4bMBfelb03s85FVMnEZQMpCd4C4Cp+sUj+5hSm2WbyV Waey7h8guz3nY5O/b86ccfu4U3xrmYLAEK64yaLkkE4fMuqlhYytNOMdzzJQVhjTgoQ8 c+mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YIHoKtHeSXxO4LyumWrPFFvJIZDXMTgh9sxej2UY0h8=; b=E8NdZlogY+ud9LkKtc0JwbXv3sAE/fGXWNeJjgSrAULr0lNt+OWjWmBYCFpvtqCO3W 7dxJlz6qwe1TWpBTqU2H50kMKaFtBdxOAY4e0uAwR4TdTGNKV5TCSE+Bdev0FS4caToh eHBnAWsC8th/13PHNfqLliySVrnSmoRcm0j+qZx5VFhjL7h+tr1SNTyNMzO68YeL47Cz +juTfpucI830/hJfSU0psdCFLxqGnhqrpEBUv7cz2BNXlO4YLp7j2vE6xqB/TruHUZTv 00qLgR3A3+1UQymXOXTXoXKIlxWuiHADCKndDfQN76/ApAM6XnhJ7YnZM/oiw99iCnCD gntg== X-Gm-Message-State: ACrzQf0WbFoN7NlkCCuG5X+Z2uW7pYzOQYyBWgaFgwLb7lv53/Y+FJsp j6TE0bl/rKF97xr7gqs4wrPcYg== X-Received: by 2002:a2e:2c12:0:b0:26f:e87b:d3aa with SMTP id s18-20020a2e2c12000000b0026fe87bd3aamr1306358ljs.315.1666106941260; Tue, 18 Oct 2022 08:29:01 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:29:00 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: [PATCH v3 4/6] PM: domains: Store the next hrtimer wakeup in genpd Date: Tue, 18 Oct 2022 17:28:35 +0200 Message-Id: <20221018152837.619426-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039821640889572?= X-GMAIL-MSGID: =?utf-8?q?1747039821640889572?= From: Maulik Shah The arch timer cannot wake up the Qualcomm Technologies, Inc. (QTI) SoCs from the deeper CPUidle states. To be able to wakeup from these deeper states, another always-on timer needs to be programmed through the so called CONTROL_TCS. As the RSC is part of CPU subsystem and the corresponding APSS RSC device is attached to the cluster PM domain (through genpd), it holds the responsibility to program the always-on timer, before entering any of these deeper CPUidle states. However, programming the timer requires information about the next hrtimer wakeup for the cluster PM domain, which is currently only known by genpd. Therefore, let's share this data through a new genpd helper function, dev_pm_genpd_get_next_hrtimer(). Signed-off-by: Maulik Shah Cc: "Rafael J. Wysocki" [Ulf: Reworked the code and updated the commit message] Signed-off-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- drivers/base/power/domain.c | 26 ++++++++++++++++++++++++++ drivers/base/power/domain_governor.c | 3 +++ include/linux/pm_domain.h | 7 +++++++ 3 files changed, 36 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index ead135c7044c..c2dec386c72e 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -494,6 +494,31 @@ void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next) } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_next_wakeup); +/** + * dev_pm_genpd_get_next_hrtimer - Return the next_hrtimer for the genpd + * @dev: A device that is attached to the genpd. + * + * This routine should typically be called for a device, at the point of when a + * GENPD_NOTIFY_PRE_OFF notification has been sent for it. + * + * Returns the aggregated value of the genpd's next hrtimer or KTIME_MAX if no + * valid value have been set. + */ +ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev) +{ + struct generic_pm_domain *genpd; + + genpd = dev_to_genpd_safe(dev); + if (!genpd) + return KTIME_MAX; + + if (genpd->gd) + return genpd->gd->next_hrtimer; + + return KTIME_MAX; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_next_hrtimer); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; @@ -1994,6 +2019,7 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd) gd->max_off_time_ns = -1; gd->max_off_time_changed = true; gd->next_wakeup = KTIME_MAX; + gd->next_hrtimer = KTIME_MAX; } /* Use only one "off" state if there were no states declared */ diff --git a/drivers/base/power/domain_governor.c b/drivers/base/power/domain_governor.c index 282a3a135827..cc2c3a5a6d35 100644 --- a/drivers/base/power/domain_governor.c +++ b/drivers/base/power/domain_governor.c @@ -375,6 +375,9 @@ static bool cpu_power_down_ok(struct dev_pm_domain *pd) if (idle_duration_ns <= 0) return false; + /* Store the next domain_wakeup to allow consumers to use it. */ + genpd->gd->next_hrtimer = domain_wakeup; + /* * Find the deepest idle state that has its residency value satisfied * and by also taking into account the power off latency for the state. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index ebc351698090..1cd41bdf73cf 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -17,6 +17,7 @@ #include #include #include +#include /* * Flags to control the behaviour of a genpd. @@ -95,6 +96,7 @@ struct genpd_governor_data { s64 max_off_time_ns; bool max_off_time_changed; ktime_t next_wakeup; + ktime_t next_hrtimer; bool cached_power_down_ok; bool cached_power_down_state_idx; }; @@ -232,6 +234,7 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); int dev_pm_genpd_add_notifier(struct device *dev, struct notifier_block *nb); int dev_pm_genpd_remove_notifier(struct device *dev); void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next); +ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -293,6 +296,10 @@ static inline int dev_pm_genpd_remove_notifier(struct device *dev) static inline void dev_pm_genpd_set_next_wakeup(struct device *dev, ktime_t next) { } +static inline ktime_t dev_pm_genpd_get_next_hrtimer(struct device *dev) +{ + return KTIME_MAX; +} #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif From patchwork Tue Oct 18 15:28:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2021574wrs; Tue, 18 Oct 2022 08:32:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4y/ACq3WyVKKfiGDbif/5t/8Qf0kEEbYbFR1L7/UKZEN4IErMzXfg/6TWxKzZE061Tcngq X-Received: by 2002:a05:6402:1941:b0:457:138:1e88 with SMTP id f1-20020a056402194100b0045701381e88mr3223796edz.394.1666107131781; Tue, 18 Oct 2022 08:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666107131; cv=none; d=google.com; s=arc-20160816; b=hxruOQp/pIyz/5mgeO9XujGNODVa0CZ35Vu3v8g6xn3BZYEN0F7iQnHsw8pQy+Qdkp sdxmp6S9tU7vYmsGf8vggApEFE0RatwwbJQ1PhhswhTD4bEGfCCvVPHuOQFqqqe8wi+h AyNyJ0hixXikbPXZWz4T6evy4w34oA27NbCVTjLPbrACb0gl05ZhwHufAvG6tuk7XKlX glZwxlupesn1R3t4D2/G2Um/1xP/HQ3+ULMYy9tEXjKQOH/MChcyozBC9rXSS5lXvxDd 89vhIqAce17r0WCa0Y75fNrWDBKHFh+Q9pBjyvf3XboodSaLTVm9px39SuRKeTBqsaME Zxww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UPjX8YygxtCcRrbYn3FxymvJ8EWixkz9W2za1oHEXVo=; b=eXz0lAl2XvPYEpqVuFZT6P1wZkVAmnvopJ+ErmsTgI7FCpAfrQU/VeOkkZGX6y9BRN YfplmeLhE0bZ+dLcQZyI2sTg66eCOY/tsuPBvT6t3n5Zb/WalsZTJYlW7RbTEx+x4Dfl WfF2V9AhCk3ZKbskt2RaTbhOCsTdlf7XbT9kcUzjypqvuWLFk6WkHu0zu+/COi37Fjbo 0ShxXlJjenWraswlKXxK7akvXcIcflqIxlBahpDX5YxaN2mIo9qeRmuN7qe+CQFW5PMK JrXnfytG/xGKn28xpwCkiWbs3JmVfwRd4k8nS0E5cfp+UuBzatSKEkHFL7qOC0/hTDpO ypgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wHWBloqi; 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 dm1-20020a05640222c100b004589ea2d983si9992971edb.287.2022.10.18.08.31.46; Tue, 18 Oct 2022 08:32:11 -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=wHWBloqi; 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 S230480AbiJRP3a (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiJRP3G (ORCPT ); Tue, 18 Oct 2022 11:29:06 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9E6BC62D for ; Tue, 18 Oct 2022 08:29:04 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id c22so17075808lja.6 for ; Tue, 18 Oct 2022 08:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UPjX8YygxtCcRrbYn3FxymvJ8EWixkz9W2za1oHEXVo=; b=wHWBloqiiwx1jqX9ysI/sEnSimM+LufKG+jyIximgCy4KFyv9/5FcYTEmQqzYo+BtF I7iAYnHfUOHyxFQJHD8JnD0vtZHDXCZuI7bMNPz9hzlE1zhXONBPzoZxS0SSW2h79IfV CG4uuKU90clSzh0UOUBaRoRQIkgovBbeqIc7ONuqcm8cfQLl1cOc4onShQdMWeLXvyK/ xr3mbBOVG1XS0UrP+vtSuy003lxBekgP8qUpJpmgG0SZ4d8+tStH0MqLqIRUhpc2JVlf +HyAs2qFzkyYoiatPzCjN5fGZisvRDzdpSo2WGqgp93USKxPoJuhcD8Abn3uVlJAVswo 9QKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UPjX8YygxtCcRrbYn3FxymvJ8EWixkz9W2za1oHEXVo=; b=DkCChkRwIReyQ5DVczKUC0n7ujJqlaqCr6UkBxwIpToHAZDuGOGslTV4qJsnsI0hfi VyvLlgCG9QqX8cXQ5lUWeV6FKC0xvX1bbIUjI9mytktH0RZvB1ad1o8Wc3HmxxiM6lOR j4VpuE8oo7GO2COu4l0udmOZyo4GuC4pa2K9V4CsSR4DG7DvLknZy5ZXi8KR/9oU5RoM HMp/k2hyRo+kGrpg+lobR4RS5CyoMqpliCVkOO4+T/0XD64yehaCTsnYGDHVQC/zLHBm GnloojUABfe2uxa1mFS8XjvidSEclMNtaLkCESeu3h/1f/U17QhZqAO+px22TbQ6c0QL psXA== X-Gm-Message-State: ACrzQf0mZpp5OooJvoYHSNs+csyXJ4vMSUMqqaCP66mkjzFVRE8i/ZN1 VUfZTg0oCTfKFH9Nz1K3/+5HEw== X-Received: by 2002:a05:651c:98a:b0:26d:fd1f:10 with SMTP id b10-20020a05651c098a00b0026dfd1f0010mr1287534ljq.323.1666106943060; Tue, 18 Oct 2022 08:29:03 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:29:02 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/6] soc: qcom: rpmh-rsc: Save base address of drv Date: Tue, 18 Oct 2022 17:28:36 +0200 Message-Id: <20221018152837.619426-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039951771349513?= X-GMAIL-MSGID: =?utf-8?q?1747039951771349513?= From: Maulik Shah Add changes to save drv's base address for rsc. This is used to read drv's configuration such as solver mode is supported or to write into CONTROL_TCS registers. Signed-off-by: Maulik Shah Reviewed-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- drivers/soc/qcom/rpmh-internal.h | 2 ++ drivers/soc/qcom/rpmh-rsc.c | 18 ++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index cd3d6ce137e3..7866bb1e5361 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -91,6 +91,7 @@ struct rpmh_ctrlr { * Resource State Coordinator controller (RSC) * * @name: Controller identifier. + * @base: Start address of the DRV registers in this controller. * @tcs_base: Start address of the TCS registers in this controller. * @id: Instance id in the controller (Direct Resource Voter). * @num_tcs: Number of TCSes in this DRV. @@ -114,6 +115,7 @@ struct rpmh_ctrlr { */ struct rsc_drv { const char *name; + void __iomem *base; void __iomem *tcs_base; int id; int num_tcs; diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 050b5f5c9f62..8e01697f59af 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -881,8 +881,7 @@ static int rpmh_rsc_pd_attach(struct rsc_drv *drv, struct device *dev) return ret; } -static int rpmh_probe_tcs_config(struct platform_device *pdev, - struct rsc_drv *drv, void __iomem *base) +static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) { struct tcs_type_config { u32 type; @@ -896,9 +895,9 @@ static int rpmh_probe_tcs_config(struct platform_device *pdev, ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset); if (ret) return ret; - drv->tcs_base = base + offset; + drv->tcs_base = drv->base + offset; - config = readl_relaxed(base + DRV_PRNT_CHLD_CONFIG); + config = readl_relaxed(drv->base + DRV_PRNT_CHLD_CONFIG); max_tcs = config; max_tcs &= DRV_NUM_TCS_MASK << (DRV_NUM_TCS_SHIFT * drv->id); @@ -960,7 +959,6 @@ static int rpmh_rsc_probe(struct platform_device *pdev) char drv_id[10] = {0}; int ret, irq; u32 solver_config; - void __iomem *base; /* * Even though RPMh doesn't directly use cmd-db, all of its children @@ -987,11 +985,11 @@ static int rpmh_rsc_probe(struct platform_device *pdev) drv->name = dev_name(&pdev->dev); snprintf(drv_id, ARRAY_SIZE(drv_id), "drv-%d", drv->id); - base = devm_platform_ioremap_resource_byname(pdev, drv_id); - if (IS_ERR(base)) - return PTR_ERR(base); + drv->base = devm_platform_ioremap_resource_byname(pdev, drv_id); + if (IS_ERR(drv->base)) + return PTR_ERR(drv->base); - ret = rpmh_probe_tcs_config(pdev, drv, base); + ret = rpmh_probe_tcs_config(pdev, drv); if (ret) return ret; @@ -1014,7 +1012,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev) * 'HW solver' mode where they can be in autonomous mode executing low * power mode to power down. */ - solver_config = readl_relaxed(base + DRV_SOLVER_CONFIG); + solver_config = readl_relaxed(drv->base + DRV_SOLVER_CONFIG); solver_config &= DRV_HW_SOLVER_MASK << DRV_HW_SOLVER_SHIFT; solver_config = solver_config >> DRV_HW_SOLVER_SHIFT; if (!solver_config) { From patchwork Tue Oct 18 15:28:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 4224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp2021872wrs; Tue, 18 Oct 2022 08:32:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7PmbLZGxM+drXMBkjs6usSMQS+XQznYM1Xn83U19Ph3yU88XLMw6d8Oi8WznvCDaZbExwH X-Received: by 2002:a05:6402:847:b0:453:943b:bf4 with SMTP id b7-20020a056402084700b00453943b0bf4mr3132634edz.301.1666107157354; Tue, 18 Oct 2022 08:32:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666107157; cv=none; d=google.com; s=arc-20160816; b=0eSu0GgMZlDLek9pZwPbg1o9KEjFos7ec++TMTExU7YxV68KUO2eh2IkU4Y5b3/Y+A jI2huOwUkLOJuzWshq9hiZ9cQ0qvOIhLnWlfcYDAQYbiu3nUoOn3WjiaWMluGNlyzN0M 8CBXbyMSvLmo2lh58wVRRZxTGlqPQeno1HR10+N0Ax1OuVdbbVW7DfnJeXDhkV2AP0OV Cus9/rm+bzWlyG/ytu4wkaalJh7TKqQ18SAgdJdv+BCWJbzWzPnu6R1XHfBx2diicSLm gbMQkguVlhJ2cYbnoraFRMvBTJ1JlHsfQPvTzGHOg+f596ntOmXELtodyqsdW3pkQ6gL U7dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eICgBxGNGKtE/hLPDQo1kEkz5yh4bfsSzqIE+62FuGc=; b=FM3hPpQ3fejgCpnh4bH3Om00MQOQH65GKsxTurdJjqzyKQZfW8Nu1LguorbpCKGHxI nOKXMOi2EeJr2VRnwpl8FE8fPv43DXBKwo3ssnH2qc0Z2pAelXFFTNFXoaMPLEcKxxtM IrAQDIz4S/djocTVlQrlAwb32IYAds8JYOoBL6fk9rJT2SSciTlVhGtiC+ZLClUyzCm2 7Gjo54tYiTruJtKOExIaMdp9c5Ngv/oSe59XOHBirqHXxBHUkQ/3O+m50HDKUfCCxUBd uuyPPus7+2EbBJWfcK3u6EXUUfMekh4BnVxtKe9fk9KEU9o/oiEggUGROqF71UuTuCKz HOFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="j6s/UUFb"; 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 j4-20020aa7c404000000b0045832636efesi10373457edq.239.2022.10.18.08.32.11; Tue, 18 Oct 2022 08:32:37 -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="j6s/UUFb"; 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 S230496AbiJRP3f (ORCPT + 99 others); Tue, 18 Oct 2022 11:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbiJRP3I (ORCPT ); Tue, 18 Oct 2022 11:29:08 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC979BC614 for ; Tue, 18 Oct 2022 08:29:06 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id i21so15547763ljh.12 for ; Tue, 18 Oct 2022 08:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eICgBxGNGKtE/hLPDQo1kEkz5yh4bfsSzqIE+62FuGc=; b=j6s/UUFbfhlBYCdMnWA56JZ+mwYLJIEgwXMq32ZQS1GcetQZ+NJTTy1Aj1+LLmDgB3 GEOhnN1Y6hIMvy4XhvzVzpYUDDn4/BbsB3kb4jeIiJfwUsDhNZ7+2ze8DwPOFohEHrr8 lncpiqcR6imDPWMC3S8/Rj0dbcYGw4y4lpv7fn0+ayfHy4mDUEE14aIzLXHH7TjSf0+U z/xy8ddv/dCz7VR+LIjWh2HtKFN8R5DOdbCJuEUFtL/x8YjQXVp3aLF0H/YI+QsJC8qT xEohCYEaRTC0JuhfrXqB+oXYVypynotGxAvo/o0/yhKGCTimVGCkN75okRTM4UxkE1R5 Jjng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eICgBxGNGKtE/hLPDQo1kEkz5yh4bfsSzqIE+62FuGc=; b=l760Br4Yx0YDXHulR1UFVZgeaMYRzJDfhlKqZkQVj70ufQAbekiStHUp+7kHG7UJwP Aa5srAD8ubwZvdj7+lIY3z4PBEhF5AWY2i+MfmrarkEuU6lUJ/1JKYQ20XUyIqXTQXIR qx4ZjUjGawESQNV6bSy1VjjtruOcIYUGf1Q6hqGPaD6VWB0aRBk/s+Nl3yvOiKqPW8K8 11WX3R22p/37s+HyXYFNvYjST+7hD4nqRZu7X74f+HDa0fPC7/q21qJXJGmY+JVgTAA+ V6dAT9d9XtsCLd3bPQwYD8hey4rMgdTZpHijCSht5tBBXDVnXA+FrW2pHcy8UdTEDU1o FwmA== X-Gm-Message-State: ACrzQf0xjENUC+tcSXbYQzUBzck80mt2/nPgKeoJGdGqEWwQeJImf/cZ 8oMXrPHc6ooKCTHOJH6z2YXRIw== X-Received: by 2002:a2e:a589:0:b0:26f:d394:dbe2 with SMTP id m9-20020a2ea589000000b0026fd394dbe2mr1327724ljp.485.1666106945164; Tue, 18 Oct 2022 08:29:05 -0700 (PDT) Received: from uffe-XPS13.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id a9-20020a05651c030900b0026ddd41aecasm1998617ljp.135.2022.10.18.08.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 08:29:04 -0700 (PDT) From: Ulf Hansson To: Andy Gross , Bjorn Andersson , Konrad Dybcio Cc: Dmitry Baryshkov , Maulik Shah , Rajendra Nayak , Sudeep Holla , Amit Pundir , Ulf Hansson , linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/6] soc: qcom: rpmh-rsc: Write CONTROL_TCS with next timer wakeup Date: Tue, 18 Oct 2022 17:28:37 +0200 Message-Id: <20221018152837.619426-7-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018152837.619426-1-ulf.hansson@linaro.org> References: <20221018152837.619426-1-ulf.hansson@linaro.org> MIME-Version: 1.0 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 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?1747039978366296732?= X-GMAIL-MSGID: =?utf-8?q?1747039978366296732?= From: Maulik Shah The next wakeup timer value needs to be set in always on domain timer as the arch timer interrupt can not wakeup the SoC if after the deepest CPUidle states the SoC also enters deepest low power state. To wakeup the SoC in such scenarios the earliest wakeup time is set in CONTROL_TCS and the firmware takes care of setting up its own timer in always on domain with next wakeup time. The timer wakes up the RSC and sets resources back to wake state. Signed-off-by: Maulik Shah Reviewed-by: Ulf Hansson Tested-by: Dmitry Baryshkov # SM8450 --- drivers/soc/qcom/rpmh-internal.h | 3 ++ drivers/soc/qcom/rpmh-rsc.c | 61 ++++++++++++++++++++++++++++++++ drivers/soc/qcom/rpmh.c | 4 ++- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 7866bb1e5361..39f53586f724 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -112,6 +112,7 @@ struct rpmh_ctrlr { * @tcs_wait: Wait queue used to wait for @tcs_in_use to free up a * slot * @client: Handle to the DRV's client. + * @dev: RSC device. */ struct rsc_drv { const char *name; @@ -127,12 +128,14 @@ struct rsc_drv { spinlock_t lock; wait_queue_head_t tcs_wait; struct rpmh_ctrlr client; + struct device *dev; }; int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); void rpmh_rsc_invalidate(struct rsc_drv *drv); +void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv); void rpmh_tx_done(const struct tcs_request *msg, int r); int rpmh_flush(struct rpmh_ctrlr *ctrlr); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 8e01697f59af..25b838bf9078 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -25,6 +26,7 @@ #include #include +#include #include #include #include @@ -49,6 +51,14 @@ #define DRV_NCPT_MASK 0x1F #define DRV_NCPT_SHIFT 27 +/* Offsets for CONTROL TCS Registers */ +#define RSC_DRV_CTL_TCS_DATA_HI 0x38 +#define RSC_DRV_CTL_TCS_DATA_HI_MASK 0xFFFFFF +#define RSC_DRV_CTL_TCS_DATA_HI_VALID BIT(31) +#define RSC_DRV_CTL_TCS_DATA_LO 0x40 +#define RSC_DRV_CTL_TCS_DATA_LO_MASK 0xFFFFFFFF +#define RSC_DRV_CTL_TCS_DATA_SIZE 32 + /* Offsets for common TCS Registers, one bit per TCS */ #define RSC_DRV_IRQ_ENABLE 0x00 #define RSC_DRV_IRQ_STATUS 0x04 @@ -142,6 +152,14 @@ * +---------------------------------------------------+ */ +#define USECS_TO_CYCLES(time_usecs) \ + xloops_to_cycles((time_usecs) * 0x10C7UL) + +static inline unsigned long xloops_to_cycles(unsigned long xloops) +{ + return (xloops * loops_per_jiffy * HZ) >> 32; +} + static inline void __iomem * tcs_reg_addr(const struct rsc_drv *drv, int reg, int tcs_id) { @@ -756,6 +774,48 @@ static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) return set < max; } +/** + * rpmh_rsc_write_next_wakeup() - Write next wakeup in CONTROL_TCS. + * @drv: The controller + * + * Writes maximum wakeup cycles when called from suspend. + * Writes earliest hrtimer wakeup when called from idle. + */ +void rpmh_rsc_write_next_wakeup(struct rsc_drv *drv) +{ + ktime_t now, wakeup; + u64 wakeup_us, wakeup_cycles = ~0; + u32 lo, hi; + + if (!drv->tcs[CONTROL_TCS].num_tcs || !drv->genpd_nb.notifier_call) + return; + + /* Set highest time when system (timekeeping) is suspended */ + if (system_state == SYSTEM_SUSPEND) + goto exit; + + /* Find the earliest hrtimer wakeup from online cpus */ + wakeup = dev_pm_genpd_get_next_hrtimer(drv->dev); + + /* Find the relative wakeup in kernel time scale */ + now = ktime_get(); + wakeup = ktime_sub(wakeup, now); + wakeup_us = ktime_to_us(wakeup); + + /* Convert the wakeup to arch timer scale */ + wakeup_cycles = USECS_TO_CYCLES(wakeup_us); + wakeup_cycles += arch_timer_read_counter(); + +exit: + lo = wakeup_cycles & RSC_DRV_CTL_TCS_DATA_LO_MASK; + hi = wakeup_cycles >> RSC_DRV_CTL_TCS_DATA_SIZE; + hi &= RSC_DRV_CTL_TCS_DATA_HI_MASK; + hi |= RSC_DRV_CTL_TCS_DATA_HI_VALID; + + writel_relaxed(lo, drv->base + RSC_DRV_CTL_TCS_DATA_LO); + writel_relaxed(hi, drv->base + RSC_DRV_CTL_TCS_DATA_HI); +} + /** * rpmh_rsc_cpu_pm_callback() - Check if any of the AMCs are busy. * @nfb: Pointer to the notifier block in struct rsc_drv. @@ -1035,6 +1095,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev) INIT_LIST_HEAD(&drv->client.batch_cache); dev_set_drvdata(&pdev->dev, drv); + drv->dev = &pdev->dev; ret = devm_of_platform_populate(&pdev->dev); if (ret && pdev->dev.pm_domain) { diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 01765ee9cdfb..3a53ed99d03c 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -450,7 +450,7 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) if (!ctrlr->dirty) { pr_debug("Skipping flush, TCS has latest data.\n"); - goto exit; + goto write_next_wakeup; } /* Invalidate the TCSes first to avoid stale data */ @@ -479,6 +479,8 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) ctrlr->dirty = false; +write_next_wakeup: + rpmh_rsc_write_next_wakeup(ctrlr_to_drv(ctrlr)); exit: spin_unlock(&ctrlr->cache_lock); return ret;