Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp617303imm; Fri, 27 Jul 2018 03:07:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdpATPAZbs2Y5aOlV5r0rUiLKjze0ZmVMgVSO4ccB9b+F0T/hAoIgVmsu553GFbWte1s0Rt X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr5485742pld.294.1532686038601; Fri, 27 Jul 2018 03:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532686038; cv=none; d=google.com; s=arc-20160816; b=fDptwpJvwQUenvvn/oJ2rxtsH00gp9YQbBoRYMEitBifYt0a4m23YmEsNykNwBF+x8 o+c9zR1Qui5Aq0SitmTJ3boVS9yoUBUqLPQerp4cuunzb0jGUfRWkU6jKoGj0s6SnidL K0reGmhCWj5sFyEkBmsyvVF11X1OoLIKlG/4IPCkgC1SU/jaVHbJUUct7bthmTQgags7 g/o+rnfJ9bJfhTuDOUueMB2rrZ+I5CUhSzpsE8zxjA37H5x++aQpI/qN+v97tmCbaNJT aHrZ36AUaPibgp5VdCHAVQcbuoi0sNXnfeDvTFHVE5IQwlnFJxHkNkiwqTKDv6fZDMgY eAXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=DKjFTcr3wQoNqB3n+WnHtOdE3DQdWk77Jo16l+VmzCc=; b=twbQ/gcIUAK4aScbJ78anYFMc5b4PSN8XY+Owh6TLFcFHtE4YUiWgSlatlW6xQM3CP 2rDx607/of/XJntumoxsCNAs8b/74+KXoEkaf19auvPc+PAX0E2W50h/eZyEptT4U8Hp TTBb9qDFMuAB2Nv9VwGgboV9qb+RrDHz/hx8wruCtKfGT8eIUrZxDa5+1oeAmm91o0aj iRCov3fDHulj3/NwGhx4CoPIJHbrfB20yK/SaQgh82P0Nj+JqCDL5mc3oWwYlfBL8x0W TCR6FwpOAw1YnEUjp9yXEyYdEcx6SdLdb9gH2jQvezUY0FacVmQobVi+sD2liIZx4E/J ot0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lTVQPeEY; dkim=pass header.i=@codeaurora.org header.s=default header.b=naqNGS6i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g70-v6si3967614pfe.4.2018.07.27.03.07.04; Fri, 27 Jul 2018 03:07:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=lTVQPeEY; dkim=pass header.i=@codeaurora.org header.s=default header.b=naqNGS6i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389347AbeG0L0V (ORCPT + 99 others); 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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,FROM_LOCAL_NOVOWEL,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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__ */ -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project