From patchwork Tue Aug 13 08:24:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 11091465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 265471398 for ; Tue, 13 Aug 2019 08:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19732285C4 for ; Tue, 13 Aug 2019 08:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D4FE285FD; Tue, 13 Aug 2019 08:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96AF2285E8 for ; Tue, 13 Aug 2019 08:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728090AbfHMIZz (ORCPT ); Tue, 13 Aug 2019 04:25:55 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:48824 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727868AbfHMIZz (ORCPT ); Tue, 13 Aug 2019 04:25:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0071F60ACA; Tue, 13 Aug 2019 08:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684754; bh=gplh7GQjZcJ4EgN1MsaY6C3S+turay46CIinA1xbsdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KH04mm5jCee/ft+dDToqSFzRkIdhL4iQY1VlTSPJVQqGRpoUGUqrF6P8mWoSu9ScW bkyEiNhZB2LCz73uFWVhp/mjleaUJLpi6TrVn4x18rfRfzs2RMYnNDJ9ch/8HIJ7vB M1Wa+JX5SBRThbdwYT22N8vq/NUGznGIbly1gejE= Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id EC7AE60909; Tue, 13 Aug 2019 08:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684753; bh=gplh7GQjZcJ4EgN1MsaY6C3S+turay46CIinA1xbsdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l9rcLFDkReVMk2Rfk/4oqQ22ECUuq1zccBas1XrxNl6s1mdjjoyfAEEoiYzE8dUNU +b3Uu21KScb7xSji6WqpjqQtfMIftqSIzPbwoGyW7+X9r6EagXCI/7WSFiekNB50LY fsMldO9tF/AzpDiy2ed15xlUmfdc16nz9K9QAJas= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EC7AE60909 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: agross@kernel.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, dianders@chromium.org, swboyd@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, ulf.hansson@linaro.org, Maulik Shah Subject: [PATCH 1/4] drivers: qcom: rpmh: fix macro to accept NULL argument Date: Tue, 13 Aug 2019 13:54:39 +0530 Message-Id: <20190813082442.25796-2-mkshah@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190813082442.25796-1-mkshah@codeaurora.org> References: <20190813082442.25796-1-mkshah@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Device argument matches with dev variable declared in RPMH message. Compiler reports error when the argument is NULL since the argument matches the name of the property. Rename dev argument to device to fix this. Signed-off-by: Maulik Shah Reviewed-by: Stephen Boyd --- drivers/soc/qcom/rpmh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 035091fd44b8..3a4579d056a4 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -23,7 +23,7 @@ #define RPMH_TIMEOUT_MS msecs_to_jiffies(10000) -#define DEFINE_RPMH_MSG_ONSTACK(dev, s, q, name) \ +#define DEFINE_RPMH_MSG_ONSTACK(device, s, q, name) \ struct rpmh_request name = { \ .msg = { \ .state = s, \ @@ -33,7 +33,7 @@ }, \ .cmd = { { 0 } }, \ .completion = q, \ - .dev = dev, \ + .dev = device, \ .needs_free = false, \ } From patchwork Tue Aug 13 08:24:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 11091471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 652DB1398 for ; Tue, 13 Aug 2019 08:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5992828445 for ; Tue, 13 Aug 2019 08:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E100285FD; Tue, 13 Aug 2019 08:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1E1D28445 for ; Tue, 13 Aug 2019 08:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728130AbfHMI0L (ORCPT ); Tue, 13 Aug 2019 04:26:11 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49054 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727793AbfHMI0L (ORCPT ); Tue, 13 Aug 2019 04:26:11 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6FB3860A24; Tue, 13 Aug 2019 08:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684769; bh=ywXBBWxMTJ6nEUmFDL5tcAalqszcOwF+FOJjszNDL4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iycE6UXAzhgJ2NQW63Hb1jrDnnsZzkdlnskCzo6sDkbr4f8teSJjCti0CZHXYBR0D ZNTrycF6/TpfdtBPZYccqAYKuHI2lqiaKdIktPm36jGHgTLX1KFJvx5Ciz5VZtmVe8 o/Y9H152BUN+ktxAa0wEivqx0TpSsj5lUD5aNRxo= Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id D287B60909; Tue, 13 Aug 2019 08:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684766; bh=ywXBBWxMTJ6nEUmFDL5tcAalqszcOwF+FOJjszNDL4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAIuNpwHyb8CsQCLnMAe+wPf8F0DDODNAew3cep8H4njKQZwRyZve+5CPkb5Kw/Fo OjBG4u3IBQqA4oKM6nm4UOCrwbxj4CtdTE5koG+ULPpK+QKpxmc65UC4kX8XANATHZ XHOwa5Y3VPUZiz9ajdHUvGWSVFlOfzpd4hSXj740= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D287B60909 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: agross@kernel.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, dianders@chromium.org, swboyd@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, ulf.hansson@linaro.org, Maulik Shah Subject: [PATCH 2/4] drivers: qcom: rpmh: remove rpmh_flush export Date: Tue, 13 Aug 2019 13:54:40 +0530 Message-Id: <20190813082442.25796-3-mkshah@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190813082442.25796-1-mkshah@codeaurora.org> References: <20190813082442.25796-1-mkshah@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rpmh_flush() was exported with the idea that an external entity operation during CPU idle would know when to flush the sleep and wake TCS. Since, this is not the case when defining a power domain for the RSC. Remove the function export and instead allow the function to be called internally. Signed-off-by: Maulik Shah Reviewed-by: Stephen Boyd --- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh.c | 18 ++++++++---------- include/soc/qcom/rpmh.h | 5 ----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index a7bbbb67991c..6eec32b97f83 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -110,5 +110,6 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, int rpmh_rsc_invalidate(struct rsc_drv *drv); void rpmh_tx_done(const struct tcs_request *msg, int r); +int rpmh_flush(struct rpmh_ctrlr *ctrlr); #endif /* __RPM_INTERNAL_H__ */ diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 3a4579d056a4..eb0ded059d2e 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -427,11 +427,10 @@ static int is_req_valid(struct cache_req *req) req->sleep_val != req->wake_val); } -static int send_single(const struct device *dev, enum rpmh_state state, +static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state, u32 addr, u32 data) { - DEFINE_RPMH_MSG_ONSTACK(dev, state, NULL, rpm_msg); - struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + DEFINE_RPMH_MSG_ONSTACK(NULL, state, NULL, rpm_msg); /* Wake sets are always complete and sleep sets are not */ rpm_msg.msg.wait_for_compl = (state == RPMH_WAKE_ONLY_STATE); @@ -445,7 +444,7 @@ static int send_single(const struct device *dev, enum rpmh_state state, /** * rpmh_flush: Flushes the buffered active and sleep sets to TCS * - * @dev: The device making the request + * @ctrlr: controller making request to flush cached data * * Return: -EBUSY if the controller is busy, probably waiting on a response * to a RPMH request sent earlier. @@ -454,10 +453,9 @@ static int send_single(const struct device *dev, enum rpmh_state state, * that is powering down the entire system. Since no other RPMH API would be * executing at this time, it is safe to run lockless. */ -int rpmh_flush(const struct device *dev) +int rpmh_flush(struct rpmh_ctrlr *ctrlr) { struct cache_req *p; - struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); int ret; if (!ctrlr->dirty) { @@ -480,11 +478,12 @@ int rpmh_flush(const struct device *dev) __func__, p->addr, p->sleep_val, p->wake_val); continue; } - ret = send_single(dev, RPMH_SLEEP_STATE, p->addr, p->sleep_val); + ret = send_single(ctrlr, RPMH_SLEEP_STATE, p->addr, + p->sleep_val); if (ret) return ret; - ret = send_single(dev, RPMH_WAKE_ONLY_STATE, - p->addr, p->wake_val); + ret = send_single(ctrlr, RPMH_WAKE_ONLY_STATE, p->addr, + p->wake_val); if (ret) return ret; } @@ -493,7 +492,6 @@ int rpmh_flush(const struct device *dev) return 0; } -EXPORT_SYMBOL(rpmh_flush); /** * rpmh_invalidate: Invalidate all sleep and active sets diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index 619e07c75da9..f9ec353d24a5 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -20,8 +20,6 @@ int rpmh_write_async(const struct device *dev, enum rpmh_state state, int rpmh_write_batch(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 *n); -int rpmh_flush(const struct device *dev); - int rpmh_invalidate(const struct device *dev); #else @@ -40,9 +38,6 @@ static inline int rpmh_write_batch(const struct device *dev, const struct tcs_cmd *cmd, u32 *n) { return -ENODEV; } -static inline int rpmh_flush(const struct device *dev) -{ return -ENODEV; } - static inline int rpmh_invalidate(const struct device *dev) { return -ENODEV; } From patchwork Tue Aug 13 08:24:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 11091473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A30021398 for ; Tue, 13 Aug 2019 08:26:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96A1628445 for ; Tue, 13 Aug 2019 08:26:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A9B328606; Tue, 13 Aug 2019 08:26:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D414285FD for ; Tue, 13 Aug 2019 08:26:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbfHMI0Y (ORCPT ); Tue, 13 Aug 2019 04:26:24 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49292 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727452AbfHMI0Y (ORCPT ); Tue, 13 Aug 2019 04:26:24 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8F10F609F3; Tue, 13 Aug 2019 08:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684783; bh=xzOhyFf1Lb46S8iAihNlSdA4LL0HPldY24aFh3YUK0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TeOOay96bcbwlqWp+6qJ6shCorX7S6h6RJKWfoaXikBl9vI399ZUn7MSJH7zGL1tp HxMvM7zDbl8BHQBXjEF9zaY4VcJSSSmlCGiPQCmsp5SqASOeFVQdpVXjOZztzh3Ie1 f5pJJoXBqL+DSFX8VZ8Rd11J5GIQKtjSsvdprcLs= Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A289760A4E; Tue, 13 Aug 2019 08:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684780; bh=xzOhyFf1Lb46S8iAihNlSdA4LL0HPldY24aFh3YUK0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frBfUD6bqYpPrAXTVl7+FVgCxgJkq800lMJIBKph9xa7tOJKG9IUZpYDRyxYYiSl/ DGFC2vowty5hzFbo3sdYtaJia4K7iEgYyfOnzoHjn1uRQoNs+tjSAGkENMuP8cuJoy 0l872hgv7nLbRxWlzTBuz27/9hjrDRnQe371WGLU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A289760A4E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: agross@kernel.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, dianders@chromium.org, swboyd@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, ulf.hansson@linaro.org, Maulik Shah , devicetree@vger.kernel.org Subject: [PATCH 3/4] dt-bindings: soc: qcom: Add RSC power domain specifier Date: Tue, 13 Aug 2019 13:54:41 +0530 Message-Id: <20190813082442.25796-4-mkshah@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190813082442.25796-1-mkshah@codeaurora.org> References: <20190813082442.25796-1-mkshah@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In addition to transmitting resource state requests to the remote processor, the RSC is responsible for powering off/lowering the requirements from CPUs subsystem for the associated hardware like buses, clocks, and regulators when all CPUs and cluster is powered down. The power domain is configured to a low power state and when all the CPUs are powered down, the RSC can lower resource state requirements and power down the rails that power the CPUs. Add PM domain specifier property for RSC controller. Cc: devicetree@vger.kernel.org Signed-off-by: Maulik Shah Reviewed-by: Stephen Boyd --- Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt b/Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt index 9b86d1eff219..d0ab6e9b6745 100644 --- a/Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt +++ b/Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt @@ -83,6 +83,13 @@ Properties: Value type: Definition: Name for the RSC. The name would be used in trace logs. +- #power-domain-cells: + Usage: optional + Value type: + Definition: Number of cells in power domain specifier. Optional for + controllers that may be in 'solver' state where they can + be in autonomous mode executing low power modes. + Drivers that want to use the RSC to communicate with RPMH must specify their bindings as child nodes of the RSC controllers they wish to communicate with. @@ -112,6 +119,7 @@ TCS-OFFSET: 0xD00 , , ; + #power-domain-cells = <0>; }; Example 2: From patchwork Tue Aug 13 08:24:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 11091481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAFF11398 for ; Tue, 13 Aug 2019 08:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFE7C27F81 for ; Tue, 13 Aug 2019 08:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3D692860A; Tue, 13 Aug 2019 08:26:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C35028448 for ; Tue, 13 Aug 2019 08:26:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbfHMI0e (ORCPT ); Tue, 13 Aug 2019 04:26:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49448 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728176AbfHMI0e (ORCPT ); Tue, 13 Aug 2019 04:26:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 20091608BA; Tue, 13 Aug 2019 08:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684793; bh=HkxmZCpMhY95DY3tCFQakYJtOGjDO+eSi569Q+9yzjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J5+E5QexOO9sgCvjSQknNHyBnBDUrLd9TTxSIeozq1rwIxYsFN1dcgJB8hhNtevUz GOOQEMRrMuXtc7rSa69eLmaKsYiN+ZHLk//rWKmYtxHfS4EL9QLsSTLQnGWue1//Om 1XsiNT/A5vxiRC9gvu+Kg4tg6YgeNfBRrb+oRNMg= Received: from mkshah-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7CC9F60A4E; Tue, 13 Aug 2019 08:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1565684789; bh=HkxmZCpMhY95DY3tCFQakYJtOGjDO+eSi569Q+9yzjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ew+f+Eaz52UrKU32eTsvKqQS6IJKbMXp/nn04WTQfIcOhphh7u4+bZuIEX6wqHNlk k19XzK2Ir4474MaxoXAqRbu5ETQ/hrKRI5bjkB+cnioVQtiThk/thGjDvDmpm9NOIz /T61+KTw8NXdV+cuYS9HVpQ3syWfHFP597qOqYZE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7CC9F60A4E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: agross@kernel.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, dianders@chromium.org, swboyd@chromium.org, rnayak@codeaurora.org, ilina@codeaurora.org, lsrao@codeaurora.org, ulf.hansson@linaro.org, Maulik Shah Subject: [PATCH 4/4] drivers: qcom: rpmh-rsc: Add RSC power domain support Date: Tue, 13 Aug 2019 13:54:42 +0530 Message-Id: <20190813082442.25796-5-mkshah@codeaurora.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190813082442.25796-1-mkshah@codeaurora.org> References: <20190813082442.25796-1-mkshah@codeaurora.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add RSC power domain support. RSC is top level power domain in hireachical CPU LPM modes. Once the rsc domain is down flush all cached sleep and wake votes from controller. Signed-off-by: Maulik Shah --- drivers/soc/qcom/rpmh-internal.h | 2 + drivers/soc/qcom/rpmh-rsc.c | 96 ++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 6eec32b97f83..3736c148effc 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -8,6 +8,7 @@ #define __RPM_INTERNAL_H__ #include +#include #include #define TCS_TYPE_NR 4 @@ -102,6 +103,7 @@ struct rsc_drv { DECLARE_BITMAP(tcs_in_use, MAX_TCS_NR); spinlock_t lock; struct rpmh_ctrlr client; + struct generic_pm_domain rsc_pd; }; int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index e278fc11fe5c..bd8e9f1a43b4 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -498,6 +498,32 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const struct tcs_request *msg) return ret; } +/** + * rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy. + * + * @drv: The controller + * + * Returns false if the TCSes are engaged in handling requests, + * True if controller is idle. + */ +static bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv) +{ + int m; + struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS); + bool ret = true; + + spin_lock(&drv->lock); + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { + if (!tcs_is_free(drv, m)) { + ret = false; + break; + } + } + spin_unlock(&drv->lock); + + return ret; +} + /** * rpmh_rsc_write_ctrl_data: Write request to the controller * @@ -521,6 +547,65 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) return tcs_ctrl_write(drv, msg); } +int rpmh_domain_power_off(struct generic_pm_domain *rsc_pd) +{ + struct rsc_drv *drv = container_of(rsc_pd, struct rsc_drv, rsc_pd); + int ret = 0; + + /* + * RPMh domain can not be powered off when there is pending ACK for + * ACTIVE_TCS request. Exit when controller is busy. + */ + + ret = rpmh_rsc_ctrlr_is_idle(drv); + if (!ret) + goto exit; + + ret = rpmh_flush(&drv->client); + if (ret) + goto exit; + +exit: + return ret; +} + +static int rpmh_probe_power_domain(struct platform_device *pdev, + struct rsc_drv *drv) +{ + int ret = -ENOMEM; + struct generic_pm_domain *rsc_pd = &drv->rsc_pd; + struct device_node *dn = pdev->dev.of_node; + + rsc_pd->name = kasprintf(GFP_KERNEL, "%s", dn->name); + if (!rsc_pd->name) + goto exit; + + rsc_pd->name = kbasename(rsc_pd->name); + rsc_pd->power_off = rpmh_domain_power_off; + rsc_pd->flags |= GENPD_FLAG_IRQ_SAFE; + + ret = pm_genpd_init(rsc_pd, NULL, false); + if (ret) + goto free_name; + + ret = of_genpd_add_provider_simple(dn, rsc_pd); + if (ret) + goto remove_pd; + + pr_debug("init PM domain %s\n", rsc_pd->name); + + return ret; + +remove_pd: + pm_genpd_remove(rsc_pd); + +free_name: + kfree(rsc_pd->name); + +exit: + return ret; +} + static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) { @@ -650,6 +735,17 @@ static int rpmh_rsc_probe(struct platform_device *pdev) if (ret) return ret; + /* + * Power domain is not required for controllers that support 'solver' + * mode where they can be in autonomous mode executing low power mode + * to power down. + */ + if (of_property_read_bool(dn, "#power-domain-cells")) { + ret = rpmh_probe_power_domain(pdev, drv); + if (ret) + return ret; + } + spin_lock_init(&drv->lock); bitmap_zero(drv->tcs_in_use, MAX_TCS_NR);