From patchwork Fri Jul 27 10:04:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546851 X-Patchwork-Delegate: agross@codeaurora.org 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 A88B31751 for ; Fri, 27 Jul 2018 10:05:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93BBC2B193 for ; Fri, 27 Jul 2018 10:05:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8518A2B1B7; Fri, 27 Jul 2018 10:05:06 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 1C8BA2B193 for ; Fri, 27 Jul 2018 10:05:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389255AbeG0L0O (ORCPT ); Fri, 27 Jul 2018 07:26:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45230 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388964AbeG0L0N (ORCPT ); Fri, 27 Jul 2018 07:26:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 785B660B74; Fri, 27 Jul 2018 10:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685902; bh=LXSvzrGk8u8GMe066kKwp4GfgpPSPfky36YVntV17nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oVnXj9DlimNKonMI9wA2QXIuDzUwhoVOLu/vy4j23uc7r1MGOMmrqwwPb+6CTfrnv usQwIT6Bkc/B1loOMQF1dNBNHAqXsZNPTVG3EXOjT3BKrAm7tzqUVDoho7yLNzl3G9 Sinm5odsKbaQlsLuRltchCfqrQp9DVzn7n9mlO7g= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 419B760B19; Fri, 27 Jul 2018 10:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685901; bh=LXSvzrGk8u8GMe066kKwp4GfgpPSPfky36YVntV17nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RlHZfpgTINCdkeYLEQpFbbsFvrtACKhGGy/3dNTy54SaAYv4KZG/Rn5ToJLkTSMWK E5b4vUnWSLLFBDOTlD5v7WrNtp3KVaInL1bGWQUuLLVRDst6TBpb/EYF50mDtVlX0L k2SH4q1OiPlckO6L9/mYYuMeRboIhQa5An5e5fno= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 419B760B19 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 1/6] drivers: qcom: rpmh-rsc: return if the controller is idle Date: Fri, 27 Jul 2018 15:34:44 +0530 Message-Id: <1532685889-31345-2-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: Lina Iyer Allow the controller status be queried. The controller is busy if it is actively processing request. Signed-off-by: Lina Iyer Signed-off-by: Raju P.L.S.S.S.N --- Changes in v2: - Remove unnecessary EXPORT_SYMBOL --- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh-rsc.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index a7bbbb6..4ff43bf 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -108,6 +108,7 @@ struct rsc_drv { int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_invalidate(struct rsc_drv *drv); +bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv); void rpmh_tx_done(const struct tcs_request *msg, int r); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 33fe9f9..42d0041 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -496,6 +496,26 @@ static int tcs_ctrl_write(struct rsc_drv *drv, const struct tcs_request *msg) } /** + * rpmh_rsc_ctrlr_is_idle: Check if any of the AMCs are busy. + * + * @drv: The controller + * + * Returns true if the TCSes are engaged in handling requests. + */ +bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv) +{ + int m; + struct tcs_group *tcs = get_tcs_of_type(drv, ACTIVE_TCS); + + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { + if (!tcs_is_free(drv, m)) + return false; + } + + return true; +} + +/** * rpmh_rsc_write_ctrl_data: Write request to the controller * * @drv: the controller From patchwork Fri Jul 27 10:04:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546861 X-Patchwork-Delegate: agross@codeaurora.org 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 53D531751 for ; Fri, 27 Jul 2018 10:05:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FB9288F7 for ; Fri, 27 Jul 2018 10:05:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3575A2B1BA; Fri, 27 Jul 2018 10:05:43 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 CE0EA288F7 for ; Fri, 27 Jul 2018 10:05:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388985AbeG0L0S (ORCPT ); Fri, 27 Jul 2018 07:26:18 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45348 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730717AbeG0L0S (ORCPT ); Fri, 27 Jul 2018 07:26:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 12C1E60B77; Fri, 27 Jul 2018 10:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685907; bh=5QeO4p7JnfaRVjRzsqyJ7ke318vLCKCr53a1pr5g8fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QRNGi+4gSx2PJdpIizbXigsVBq8Xzoj0Gxg9sEZxIiusDGJmoKpyA2N/bcSJsX4FN RPDDI531c3+dRu6+IlnPnnTSLXL1IXavV7wVU3MwBviuK2VgdLl/tr2dgsrrTLEbjs zzzjHX+jIz5ru8kcpSqUYsZNs806GfteQBbpEUVo= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 38FE8607B9; Fri, 27 Jul 2018 10:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685905; bh=5QeO4p7JnfaRVjRzsqyJ7ke318vLCKCr53a1pr5g8fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOaTm4dUn0TeoAzWT5sQabIahC+gVxyRCoXz+6BLeSvo3KFTGs8de6zYeFa1BZuuu y29e7Dh86DerUmC9WJXGbTWU+p021lTOIp5axAxsDeLM66srMbePC0Nvv/4l6Ygo3N S99Z/83HHegCRu2OFZEK9ji37QfhWSc0STdYIMog= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 38FE8607B9 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 2/6] drivers: qcom: rpmh: export controller idle status Date: Fri, 27 Jul 2018 15:34:45 +0530 Message-Id: <1532685889-31345-3-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: Lina Iyer Allow the controller state be read by platform drivers. This is useful for PM drivers which can choose to disallow idle modes when the controller is busy. Signed-off-by: Lina Iyer Signed-off-by: Raju P.L.S.S.S.N --- drivers/soc/qcom/rpmh.c | 13 +++++++++++++ include/soc/qcom/rpmh.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index c7beb68..2382276 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -511,3 +511,16 @@ int rpmh_invalidate(const struct device *dev) return ret; } EXPORT_SYMBOL(rpmh_invalidate); + +/** + * rpmh_ctrlr_idle: Return the controller idle status + * + * @dev: the device making the request + */ +int rpmh_ctrlr_idle(const struct device *dev) +{ + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + + return rpmh_rsc_ctrlr_is_idle(ctrlr_to_drv(ctrlr)); +} +EXPORT_SYMBOL(rpmh_ctrlr_idle); diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index 619e07c..d445322 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -24,6 +24,8 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, int rpmh_invalidate(const struct device *dev); +int rpmh_ctrlr_idle(const struct device *dev); + #else static inline int rpmh_write(const struct device *dev, enum rpmh_state state, @@ -46,6 +48,9 @@ static inline int rpmh_flush(const struct device *dev) static inline int rpmh_invalidate(const struct device *dev) { return -ENODEV; } +static inline int rpmh_ctrlr_idle(const struct device *dev) +{ return -ENODEV; } + #endif /* CONFIG_QCOM_RPMH */ #endif /* __SOC_QCOM_RPMH_H__ */ From patchwork Fri Jul 27 10:04:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546853 X-Patchwork-Delegate: agross@codeaurora.org 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 8A5E3112B for ; Fri, 27 Jul 2018 10:05:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785AA2B193 for ; Fri, 27 Jul 2018 10:05:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BE152B1B7; Fri, 27 Jul 2018 10:05:13 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D3AAD2B193 for ; Fri, 27 Jul 2018 10:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389323AbeG0L0V (ORCPT ); Fri, 27 Jul 2018 07:26:21 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45446 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730717AbeG0L0V (ORCPT ); Fri, 27 Jul 2018 07:26:21 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6E30760B81; Fri, 27 Jul 2018 10:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685910; bh=1GVpPZwuOFhg8HYL/RGEWA5mK4KpgXhYR4iqx29KKfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lTVQPeEYPqre1mwoFP+D29Qra+KY4j4YsLZkZ+9jFXLahymPz0rUl38oEoqtXzzxb ok7f4NuazVmqfytUhWAbxp21ccnDfNSLEPyeaoecbaqDPTHO0PvOphQ5J/Cur+b76s kEPErp2+6MmiL+d6egYXOuxJZO8epaJWwGT4gUEE= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 356F160B15; Fri, 27 Jul 2018 10:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685909; bh=1GVpPZwuOFhg8HYL/RGEWA5mK4KpgXhYR4iqx29KKfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=naqNGS6iZHRZMGS192JimhXdvIZOWphBpdPB5yHmPCRB2vKuEqE/Is5xYqUsfhH3G H5JDlR+hRDGdP7BEILe21NNOSyunnTdmoUOSF/yPqMg69foqkLk9PcGxhvRdN73uTp 0ELg6AsIh7BR7VTDCCtOk+ZBRzarbH4EWcyhmcHw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 356F160B15 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 3/6] drivers: qcom: rpmh: disallow active requests in solver mode Date: Fri, 27 Jul 2018 15:34:46 +0530 Message-Id: <1532685889-31345-4-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: Lina Iyer Controllers may be in 'solver' state, where they could be in autonomous mode executing low power modes for their hardware and as such are not available for sending active votes. Device driver may notify RPMH API that the controller is in solver mode and when in such mode, disallow requests from platform drivers for state change using the RSC. Signed-off-by: Lina Iyer Signed-off-by: Raju P.L.S.S.S.N --- drivers/soc/qcom/rpmh-internal.h | 2 ++ drivers/soc/qcom/rpmh.c | 59 ++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/rpmh.h | 5 ++++ 3 files changed, 66 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 4ff43bf..6cd2f78 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -72,12 +72,14 @@ struct rpmh_request { * @cache_lock: synchronize access to the cache data * @dirty: was the cache updated since flush * @batch_cache: Cache sleep and wake requests sent as batch + * @in_solver_mode: Controller is busy in solver mode */ struct rpmh_ctrlr { struct list_head cache; spinlock_t cache_lock; bool dirty; struct list_head batch_cache; + bool in_solver_mode; }; /** diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 2382276..0d276fd 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,50 @@ static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev) return &drv->client; } +static int check_ctrlr_state(struct rpmh_ctrlr *ctrlr, enum rpmh_state state) +{ + unsigned long flags; + int ret = 0; + + /* Do not allow setting active votes when in solver mode */ + spin_lock_irqsave(&ctrlr->cache_lock, flags); + if (ctrlr->in_solver_mode && state == RPMH_ACTIVE_ONLY_STATE) + ret = -EBUSY; + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + + return ret; +} + +/** + * rpmh_mode_solver_set: Indicate that the RSC controller hardware has + * been configured to be in solver mode + * + * @dev: the device making the request + * @enable: Boolean value indicating if the controller is in solver mode. + * + * When solver mode is enabled, passthru API will not be able to send wake + * votes, just awake and active votes. + */ +int rpmh_mode_solver_set(const struct device *dev, bool enable) +{ + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + unsigned long flags; + + for (;;) { + spin_lock_irqsave(&ctrlr->cache_lock, flags); + if (rpmh_rsc_ctrlr_is_idle(ctrlr_to_drv(ctrlr))) { + ctrlr->in_solver_mode = enable; + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + break; + } + spin_unlock_irqrestore(&ctrlr->cache_lock, flags); + udelay(10); + } + + return 0; +} +EXPORT_SYMBOL(rpmh_mode_solver_set); + void rpmh_tx_done(const struct tcs_request *msg, int r) { struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request, @@ -231,8 +276,13 @@ int rpmh_write_async(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n) { struct rpmh_request *rpm_msg; + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); int ret; + ret = check_ctrlr_state(ctrlr, state); + if (ret) + return ret; + rpm_msg = kzalloc(sizeof(*rpm_msg), GFP_ATOMIC); if (!rpm_msg) return -ENOMEM; @@ -263,11 +313,16 @@ int rpmh_write(const struct device *dev, enum rpmh_state state, { DECLARE_COMPLETION_ONSTACK(compl); DEFINE_RPMH_MSG_ONSTACK(dev, state, &compl, rpm_msg); + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); int ret; if (!cmd || !n || n > MAX_RPMH_PAYLOAD) return -EINVAL; + ret = check_ctrlr_state(ctrlr, state); + if (ret) + return ret; + memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd)); rpm_msg.msg.num_cmds = n; @@ -357,6 +412,10 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, if (!cmd || !n) return -EINVAL; + ret = check_ctrlr_state(ctrlr, state); + if (ret) + return ret; + while (n[count] > 0) count++; if (!count) diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index d445322..018788d 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -26,6 +26,8 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, int rpmh_ctrlr_idle(const struct device *dev); +int rpmh_mode_solver_set(const struct device *dev, bool enable); + #else static inline int rpmh_write(const struct device *dev, enum rpmh_state state, @@ -51,6 +53,9 @@ static inline int rpmh_invalidate(const struct device *dev) static inline int rpmh_ctrlr_idle(const struct device *dev) { return -ENODEV; } +static inline int rpmh_mode_solver_set(const struct device *dev, bool enable) +{ return -ENODEV; } + #endif /* CONFIG_QCOM_RPMH */ #endif /* __SOC_QCOM_RPMH_H__ */ From patchwork Fri Jul 27 10:04:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546859 X-Patchwork-Delegate: agross@codeaurora.org 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 50C00112B for ; Fri, 27 Jul 2018 10:05:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E873288F7 for ; Fri, 27 Jul 2018 10:05:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32E352B1BA; Fri, 27 Jul 2018 10:05:40 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 D37F4288F7 for ; Fri, 27 Jul 2018 10:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389291AbeG0L00 (ORCPT ); Fri, 27 Jul 2018 07:26:26 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45576 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730717AbeG0L0Z (ORCPT ); Fri, 27 Jul 2018 07:26:25 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id BCF2860B73; Fri, 27 Jul 2018 10:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685914; bh=Ysj2qPcfLbjvsDV1B+2zCcWTDLL3kMdQk9mUedzAAok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcCP75tIJF0n7tCAXQ+4HpEHtEh9VGuf9KSgNcT3WYrbOyuM1CpxFWxl9u7W8vunY n9fZpuXTSTtKhrWU+A3fM8kFMiCKFplcsWHrbdOUtp1n/ry+jIGWA7aXp3y3L3d6ob CpB/HlmmGisAjwwMD4cg5y9Zwr8UJh4/PKjdD99k= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0019860B7E; Fri, 27 Jul 2018 10:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685913; bh=Ysj2qPcfLbjvsDV1B+2zCcWTDLL3kMdQk9mUedzAAok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y8DIM4+rTZp3JI9bXUo79AeXpbsqBJMhzqIVpEPk5gGkDBZrhZqvKMQTpbOM1cP7U 93OjUpOQw6OfdxT3aHti6UTgQ/W7QqQkI3FgCoJozQ34/x8a5r3xWXzCfcJDLDcvqx LavBt+Xm/8YL27yb8X0SC7D9+phC1C7CPn7TzrcY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0019860B7E 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 4/6] drivers: qcom: rpmh-rsc: clear active mode configuration for waketcs Date: Fri, 27 Jul 2018 15:34:47 +0530 Message-Id: <1532685889-31345-5-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: "Raju P.L.S.S.S.N" For RSCs that have sleep & wake TCS but no dedicated active TCS, wake TCS can be re-purposed to send active requests. Once the active requests are sent and response is received, the active mode configuration needs to be cleared so that controller can use wake TCS for sending wake requests in 'solver' state while executing low power modes. Signed-off-by: Raju P.L.S.S.S.N Reviewed-by: Matthias Kaehlcke --- drivers/soc/qcom/rpmh-rsc.c | 77 +++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 42d0041..19616c9 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -199,6 +199,42 @@ static const struct tcs_request *get_req_from_tcs(struct rsc_drv *drv, return NULL; } +static void __tcs_trigger(struct rsc_drv *drv, int tcs_id, bool trigger) +{ + u32 enable; + + /* + * HW req: Clear the DRV_CONTROL and enable TCS again + * While clearing ensure that the AMC mode trigger is cleared + * and then the mode enable is cleared. + */ + enable = read_tcs_reg(drv, RSC_DRV_CONTROL, tcs_id, 0); + enable &= ~TCS_AMC_MODE_TRIGGER; + write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); + enable &= ~TCS_AMC_MODE_ENABLE; + write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); + + if (trigger) { + /* Enable the AMC mode on the TCS and then trigger the TCS */ + enable = TCS_AMC_MODE_ENABLE; + write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); + enable |= TCS_AMC_MODE_TRIGGER; + write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); + } +} + +static inline void enable_tcs_irq(struct rsc_drv *drv, int tcs_id, bool enable) +{ + u32 data; + + data = read_tcs_reg(drv, RSC_DRV_IRQ_ENABLE, 0, 0); + if (enable) + data |= BIT(tcs_id); + else + data &= ~BIT(tcs_id); + write_tcs_reg(drv, RSC_DRV_IRQ_ENABLE, 0, data); +} + /** * tcs_tx_done: TX Done interrupt handler */ @@ -235,6 +271,21 @@ static irqreturn_t tcs_tx_done(int irq, void *p) } trace_rpmh_tx_done(drv, i, req, err); + + /* + * if wake tcs was re-purposed for sending active + * votes, clear AMC trigger & enable modes and + * disable interrupt for this TCS + */ + if (!drv->tcs[ACTIVE_TCS].num_tcs) { + __tcs_trigger(drv, i, false); + /* + * Disable interrupt for this TCS to avoid being + * spammed with interrupts coming when the solver + * sends its wake votes. + */ + enable_tcs_irq(drv, i, false); + } skip: /* Reclaim the TCS */ write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i, 0); @@ -282,28 +333,6 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, write_tcs_reg(drv, RSC_DRV_CMD_ENABLE, tcs_id, cmd_enable); } -static void __tcs_trigger(struct rsc_drv *drv, int tcs_id) -{ - u32 enable; - - /* - * HW req: Clear the DRV_CONTROL and enable TCS again - * While clearing ensure that the AMC mode trigger is cleared - * and then the mode enable is cleared. - */ - enable = read_tcs_reg(drv, RSC_DRV_CONTROL, tcs_id, 0); - enable &= ~TCS_AMC_MODE_TRIGGER; - write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); - enable &= ~TCS_AMC_MODE_ENABLE; - write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); - - /* Enable the AMC mode on the TCS and then trigger the TCS */ - enable = TCS_AMC_MODE_ENABLE; - write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); - enable |= TCS_AMC_MODE_TRIGGER; - write_tcs_reg_sync(drv, RSC_DRV_CONTROL, tcs_id, enable); -} - static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, const struct tcs_request *msg) { @@ -374,10 +403,12 @@ static int tcs_write(struct rsc_drv *drv, const struct tcs_request *msg) tcs->req[tcs_id - tcs->offset] = msg; set_bit(tcs_id, drv->tcs_in_use); + if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) + enable_tcs_irq(drv, tcs_id, true); spin_unlock(&drv->lock); __tcs_buffer_write(drv, tcs_id, 0, msg); - __tcs_trigger(drv, tcs_id); + __tcs_trigger(drv, tcs_id, true); done_write: spin_unlock_irqrestore(&tcs->lock, flags); From patchwork Fri Jul 27 10:04:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546855 X-Patchwork-Delegate: agross@codeaurora.org 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 EFCF6112B for ; Fri, 27 Jul 2018 10:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF249288F7 for ; Fri, 27 Jul 2018 10:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D377F2B1BA; Fri, 27 Jul 2018 10:05: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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 574A5288F7 for ; Fri, 27 Jul 2018 10:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389382AbeG0L0a (ORCPT ); Fri, 27 Jul 2018 07:26:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45664 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730583AbeG0L03 (ORCPT ); Fri, 27 Jul 2018 07:26:29 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8B83B60AD8; Fri, 27 Jul 2018 10:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685918; bh=AWlzHpxCyRNs8hW3hy9P+OeRkDJE+u3SIVRKvtqMvmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ivLK/vkXs1Ch3irrmzYrhgGIsOARbd9ZnhzY8S/4tF2rZ8YdVVqpfS1S+4igFOKkV jFcpCdhSToFeERgvbRLgObUad+9Ptt/RImSYItFrzRPILbKuB06450y0xJ+E5cvPNv 2pBvF2NHZdmjYAs8BIlnBMIIZX+2DPPVhFsep9m4= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 104C2605BD; Fri, 27 Jul 2018 10:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685917; bh=AWlzHpxCyRNs8hW3hy9P+OeRkDJE+u3SIVRKvtqMvmw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQFl+T1gmyyfaDQ01MDTDjLs9gg5GLDWScSU7eilXJnOAZta205fsPf8Tfkl30YuG X0HVL/USz8kk+vuUvyAexJqCWZERHY57rJih3iYzdEafexiRzkOVPXrgONmNp8KArY HTkrPxiuC2mdn5cB+nw7HTAJy+RzC0T5VcTARNSQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 104C2605BD 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 5/6] drivers: qcom: rpmh-rsc: write PDC data Date: Fri, 27 Jul 2018 15:34:48 +0530 Message-Id: <1532685889-31345-6-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: Lina Iyer The Power Domain Controller can be programmed to wakeup the RSC and setup the resources back in the active state, before the processor is woken up by a timer interrupt. The wakeup value from the timer hardware can be copied to the PDC which has its own timer and is in an always-on power domain. Programming the wakeup value is done through a separate register on the RSC. Signed-off-by: Lina Iyer Signed-off-by: Raju P.L.S.S.S.N Reviewed-by: Matthias Kaehlcke --- Changes in v2: - Remove unnecessary EXPORT_SYMBOL --- drivers/soc/qcom/rpmh-internal.h | 3 +++ drivers/soc/qcom/rpmh-rsc.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 6cd2f78..f5359be 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -87,6 +87,7 @@ struct rpmh_ctrlr { * Resource State Coordinator controller (RSC) * * @name: controller identifier + * @base: start address of the RSC's DRV registers * @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 @@ -97,6 +98,7 @@ struct rpmh_ctrlr { */ struct rsc_drv { const char *name; + void __iomem *base; void __iomem *tcs_base; int id; int num_tcs; @@ -111,6 +113,7 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_invalidate(struct rsc_drv *drv); bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv); +int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request *msg); void rpmh_tx_done(const struct tcs_request *msg, int r); diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 19616c9..c870477 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -60,6 +60,11 @@ #define CMD_STATUS_ISSUED BIT(8) #define CMD_STATUS_COMPL BIT(16) +/* PDC wakeup */ +#define RSC_PDC_DATA_SIZE 2 +#define RSC_PDC_DRV_DATA 0x38 +#define RSC_PDC_DATA_OFFSET 0x08 + static u32 read_tcs_reg(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id) { return readl_relaxed(drv->tcs_base + reg + RSC_DRV_TCS_OFFSET * tcs_id + @@ -569,6 +574,25 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) return tcs_ctrl_write(drv, msg); } +int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request *msg) +{ + int i; + void __iomem *addr = drv->base + RSC_PDC_DRV_DATA; + + if (!msg || !msg->cmds || msg->num_cmds != RSC_PDC_DATA_SIZE) + return -EINVAL; + + for (i = 0; i < msg->num_cmds; i++) { + /* Only data is write capable */ + writel_relaxed(msg->cmds[i].data, addr); + trace_rpmh_send_msg(drv, RSC_PDC_DRV_DATA, i, 0, + &msg->cmds[i]); + addr += RSC_PDC_DATA_OFFSET; + } + + return 0; +} + static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) { @@ -581,21 +605,20 @@ static int rpmh_probe_tcs_config(struct platform_device *pdev, int i, ret, n, st = 0; struct tcs_group *tcs; struct resource *res; - void __iomem *base; char drv_id[10] = {0}; snprintf(drv_id, ARRAY_SIZE(drv_id), "drv-%d", drv->id); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, drv_id); - base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + drv->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(drv->base)) + return PTR_ERR(drv->base); 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); From patchwork Fri Jul 27 10:04:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Raju P.L.S.S.S.N" X-Patchwork-Id: 10546857 X-Patchwork-Delegate: agross@codeaurora.org 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 9212C112B for ; Fri, 27 Jul 2018 10:05:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80EF3288F7 for ; Fri, 27 Jul 2018 10:05:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74C212B1BA; Fri, 27 Jul 2018 10:05:32 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 0D182288F7 for ; Fri, 27 Jul 2018 10:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388525AbeG0L0e (ORCPT ); Fri, 27 Jul 2018 07:26:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45790 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730583AbeG0L0e (ORCPT ); Fri, 27 Jul 2018 07:26:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 176F3605BD; Fri, 27 Jul 2018 10:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685923; bh=OYwO4O5rh9WnYpi/3ZUQMm8Dx9PKKJlPkbG76fpXTe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izpYiRZJKlXt/+N2lCoBcmdJERI++ubCVe0O0p9oj0WYnGNGK3JxyDE7Y2AAkQjkQ kmUIrV76HJ9Xbu9klYdCer+gNyMB0LpETB6XOwUiUyUN+8ZpkNhqUh+lR1INjheUbs IMG4apZYXdpmxRSX0XSwSxKPcDtP8WKI3ixK05os= Received: from rplsssn-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: rplsssn@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3B7D460B81; Fri, 27 Jul 2018 10:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532685921; bh=OYwO4O5rh9WnYpi/3ZUQMm8Dx9PKKJlPkbG76fpXTe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WLZSXJB2PUwk5U66DHanaWTuhHwdfmDm5zYjSTxdeMH/eDpaYiyX3JoQ1+FBNKbFF 7m5IZYjGXSlXOmCWqKKxLGz29ouJlQem8orlbtC77VPXzFgucjhRl76IQrG+eHWbJ3 uSMeE0rBMIAnAae5wsbs4UyCKy9ULIk53xUNrYyQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3B7D460B81 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=rplsssn@codeaurora.org From: Raju P L S S S N To: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org, mka@chromium.org, ilina@codeaurora.org, "Raju P.L.S.S.S.N" Subject: [PATCH v2 6/6] drivers: qcom: rpmh: write PDC data Date: Fri, 27 Jul 2018 15:34:49 +0530 Message-Id: <1532685889-31345-7-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> References: <1532685889-31345-1-git-send-email-rplsssn@codeaurora.org> 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 From: Lina Iyer In addition to requests that are send to the remote processor, the controller may allow certain data to be written to the controller for use in specific cases like wakeup value when entering idle states. Allow a pass through to write PDC data. Signed-off-by: Lina Iyer Signed-off-by: Raju P.L.S.S.S.N Reviewed-by: Matthias Kaehlcke --- drivers/soc/qcom/rpmh.c | 28 ++++++++++++++++++++++++++++ include/soc/qcom/rpmh.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 0d276fd..f81488b 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -472,6 +472,34 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, } EXPORT_SYMBOL(rpmh_write_batch); +/** + * rpmh_write_pdc_data: Write PDC data to the controller + * + * @dev: the device making the request + * @cmd: The payload data + * @n: The number of elements in payload + * + * Write PDC data to the controller. The messages are always sent async. + * + * May be called from atomic contexts. + */ +int rpmh_write_pdc_data(const struct device *dev, + const struct tcs_cmd *cmd, u32 n) +{ + DEFINE_RPMH_MSG_ONSTACK(dev, 0, NULL, rpm_msg); + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + + if (!n || n > MAX_RPMH_PAYLOAD) + return -EINVAL; + + memcpy(rpm_msg.cmd, cmd, n * sizeof(*cmd)); + rpm_msg.msg.num_cmds = n; + rpm_msg.msg.wait_for_compl = false; + + return rpmh_rsc_write_pdc_data(ctrlr_to_drv(ctrlr), &rpm_msg.msg); +} +EXPORT_SYMBOL(rpmh_write_pdc_data); + static int is_req_valid(struct cache_req *req) { return (req->sleep_val != UINT_MAX && diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index 018788d..d5e736e 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -28,6 +28,9 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, int rpmh_mode_solver_set(const struct device *dev, bool enable); +int rpmh_write_pdc_data(const struct device *dev, + const struct tcs_cmd *cmd, u32 n); + #else static inline int rpmh_write(const struct device *dev, enum rpmh_state state, @@ -56,6 +59,9 @@ static inline int rpmh_ctrlr_idle(const struct device *dev) static inline int rpmh_mode_solver_set(const struct device *dev, bool enable) { return -ENODEV; } +static inline int rpmh_write_pdc_data(const struct device *dev, + const struct tcs_cmd *cmd, u32 n) +{ return -ENODEV; } #endif /* CONFIG_QCOM_RPMH */ #endif /* __SOC_QCOM_RPMH_H__ */