From patchwork Mon Jan 25 06:20:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 12043113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E73C433E0 for ; Mon, 25 Jan 2021 09:12:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F1CB22DFB for ; Mon, 25 Jan 2021 09:12:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726092AbhAYJHA (ORCPT ); Mon, 25 Jan 2021 04:07:00 -0500 Received: from m42-8.mailgun.net ([69.72.42.8]:52405 "EHLO m42-8.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbhAYGWD (ORCPT ); Mon, 25 Jan 2021 01:22:03 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1611555673; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=031CmOz7IHwqK2RKXiiWONMufFviMXMNdtPF56c9Nb4=; b=GAd24/JMe5N49hkIEalpFcCwtZkvT8EdRti/SapzL+RVdpFbJrsQ1vAQOsjdMDv4p/m7ptbL BCZ/foySTk2FkyQFdz4RZrExx6R2QtBZbmkUUhTihvp5zW8Rdi+hdUnxbXijqDuNJxUAG/d3 Fam1gm3ydr3XkrS+LjtAAhYrtzw= X-Mailgun-Sending-Ip: 69.72.42.8 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 600e633fd75e1218e3eb5cbc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 25 Jan 2021 06:20:47 GMT Sender: mkshah=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8E13BC43461; Mon, 25 Jan 2021 06:20:46 +0000 (UTC) Received: from mkshah-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 90D8EC433C6; Mon, 25 Jan 2021 06:20:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 90D8EC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, agross@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tkjos@google.com, dianders@chromium.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v2 1/3] drivers: qcom: rpmh: Disallow active requests in solver mode Date: Mon, 25 Jan 2021 11:50:35 +0530 Message-Id: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 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: Maulik Shah --- (no changes since v1) --- drivers/soc/qcom/rpmh-internal.h | 5 ++++ drivers/soc/qcom/rpmh-rsc.c | 31 ++++++++++++++++++++++ drivers/soc/qcom/rpmh.c | 56 ++++++++++++++++++++++++++++++++++++++++ drivers/soc/qcom/trace-rpmh.h | 20 ++++++++++++++ include/soc/qcom/rpmh.h | 5 ++++ 5 files changed, 117 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 344ba68..79486d6 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -77,12 +77,14 @@ struct rpmh_request { * @cache: the list of cached requests * @cache_lock: synchronize access to the cache data * @dirty: was the cache updated since flush + * @in_solver_mode: Controller is busy in solver mode * @batch_cache: Cache sleep and wake requests sent as batch */ struct rpmh_ctrlr { struct list_head cache; spinlock_t cache_lock; bool dirty; + bool in_solver_mode; struct list_head batch_cache; }; @@ -94,6 +96,7 @@ struct rpmh_ctrlr { * @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. + * @in_solver_mode: Controller is busy in solver mode * @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. @@ -116,6 +119,7 @@ struct rsc_drv { void __iomem *tcs_base; int id; int num_tcs; + bool in_solver_mode; struct notifier_block rsc_pm; atomic_t cpus_in_pm; struct tcs_group tcs[TCS_TYPE_NR]; @@ -129,6 +133,7 @@ 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); +int rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable); 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 a84ab0d..1c1f5b0 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -635,6 +635,12 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg) spin_lock_irqsave(&drv->lock, flags); + if (drv->in_solver_mode) { + /* Controller is busy in 'solver' mode */ + spin_unlock_irqrestore(&drv->lock, flags); + return -EBUSY; + } + /* Wait forever for a free tcs. It better be there eventually! */ wait_event_lock_irq(drv->tcs_wait, (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0, @@ -855,6 +861,31 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb, return ret; } +/** + * rpmh_rsc_mode_solver_set() - Enable/disable solver mode. + * @drv: The controller. + * @enable: Boolean state to be set - true/false + * + * Return: + * * 0 - success + * * -EBUSY - AMCs are busy + */ +int rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable) +{ + int ret = -EBUSY; + + if (spin_trylock(&drv->lock)) { + if (!enable || !rpmh_rsc_ctrlr_is_busy(drv)) { + drv->in_solver_mode = enable; + trace_rpmh_solver_set(drv, enable); + ret = 0; + } + spin_unlock(&drv->lock); + } + + return ret; +} + static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv, void __iomem *base) { diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 01765ee..cbe6b96 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -76,6 +76,22 @@ 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) +{ + int ret = 0; + + if (state != RPMH_ACTIVE_ONLY_STATE) + return ret; + + /* Do not allow sending active votes when in solver mode */ + spin_lock(&ctrlr->cache_lock); + if (ctrlr->in_solver_mode) + ret = -EBUSY; + spin_unlock(&ctrlr->cache_lock); + + return ret; +} + void rpmh_tx_done(const struct tcs_request *msg, int r) { struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request, @@ -229,9 +245,14 @@ static int __fill_rpmh_msg(struct rpmh_request *req, enum rpmh_state state, int rpmh_write_async(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n) { + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); struct rpmh_request *rpm_msg; 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; @@ -262,8 +283,13 @@ 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; + ret = check_ctrlr_state(ctrlr, state); + if (ret) + return ret; + ret = __fill_rpmh_msg(&rpm_msg, state, cmd, n); if (ret) return ret; @@ -338,6 +364,10 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, int ret, i; void *ptr; + ret = check_ctrlr_state(ctrlr, state); + if (ret) + return ret; + if (!cmd || !n) return -EINVAL; @@ -505,3 +535,29 @@ void rpmh_invalidate(const struct device *dev) spin_unlock_irqrestore(&ctrlr->cache_lock, flags); } EXPORT_SYMBOL(rpmh_invalidate); + +/** + * 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. + * + * Return: + * * 0 - Success + * * Error code - Otherwise + */ +int rpmh_mode_solver_set(const struct device *dev, bool enable) +{ + int ret; + struct rpmh_ctrlr *ctrlr = get_rpmh_ctrlr(dev); + + spin_lock(&ctrlr->cache_lock); + ret = rpmh_rsc_mode_solver_set(ctrlr_to_drv(ctrlr), enable); + if (!ret) + ctrlr->in_solver_mode = enable; + spin_unlock(&ctrlr->cache_lock); + + return ret; +} +EXPORT_SYMBOL(rpmh_mode_solver_set); diff --git a/drivers/soc/qcom/trace-rpmh.h b/drivers/soc/qcom/trace-rpmh.h index feb0cb4..b2b934c 100644 --- a/drivers/soc/qcom/trace-rpmh.h +++ b/drivers/soc/qcom/trace-rpmh.h @@ -71,6 +71,26 @@ TRACE_EVENT(rpmh_send_msg, __entry->addr, __entry->data, __entry->wait) ); +TRACE_EVENT(rpmh_solver_set, + + TP_PROTO(struct rsc_drv *d, bool set), + + TP_ARGS(d, set), + + TP_STRUCT__entry( + __string(name, d->name) + __field(bool, set) + ), + + TP_fast_assign( + __assign_str(name, d->name); + __entry->set = set; + ), + + TP_printk("%s: solver mode set: %d", + __get_str(name), __entry->set) +); + #endif /* _TRACE_RPMH_H */ #undef TRACE_INCLUDE_PATH diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index bdbee1a..fa8bb53 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -20,6 +20,8 @@ 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_mode_solver_set(const struct device *dev, bool enable); + void rpmh_invalidate(const struct device *dev); #else @@ -38,6 +40,9 @@ static inline int rpmh_write_batch(const struct device *dev, const struct tcs_cmd *cmd, u32 *n) { return -ENODEV; } +static int rpmh_mode_solver_set(const struct device *dev, bool enable) +{ return -ENODEV; } + static inline void rpmh_invalidate(const struct device *dev) { } From patchwork Mon Jan 25 06:20:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 12043111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB910C433DB for ; Mon, 25 Jan 2021 09:07:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69DB122EBD for ; Mon, 25 Jan 2021 09:07:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725880AbhAYJGw (ORCPT ); Mon, 25 Jan 2021 04:06:52 -0500 Received: from m42-8.mailgun.net ([69.72.42.8]:50543 "EHLO m42-8.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727063AbhAYGWJ (ORCPT ); Mon, 25 Jan 2021 01:22:09 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1611555677; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=n51NmrhCqqNMGc+z6xxnaJLMBlKY1MVhckYbF79Fvlc=; b=wEXJrV0tC9kzvqvu3Yc/n+peowbcmV/j4qndNsDj7J50o1v5f6yOGV+hHV2vhZ17O/DB7xvX a4CIJN0tK6cgjtFMYUV+1rqSeHJf6/8x9ByabYbEnP0IcX9AjuDeSl48Ng8Fi4YrtfN7IS6d nOxXX7Y6RpDDB0waC8EV2D/G1p4= X-Mailgun-Sending-Ip: 69.72.42.8 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 600e6342d75e1218e3eb6076 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 25 Jan 2021 06:20:50 GMT Sender: mkshah=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8E985C43463; Mon, 25 Jan 2021 06:20:49 +0000 (UTC) Received: from mkshah-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 074ECC433CA; Mon, 25 Jan 2021 06:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 074ECC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, agross@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tkjos@google.com, dianders@chromium.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v2 2/3] soc: qcom: rpmh: Add rpmh_write_sleep_and_wake() function Date: Mon, 25 Jan 2021 11:50:36 +0530 Message-Id: <1611555637-7688-2-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org> References: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let RPMH clients call rpmh_write_sleep_and_wake() to immediately write cached sleep and wake data to the TCSes. Signed-off-by: Maulik Shah --- (no changes since v1) --- drivers/soc/qcom/rpmh.c | 16 ++++++++++++++++ include/soc/qcom/rpmh.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index cbe6b96..725b8f0 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -515,6 +515,22 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) } /** + * rpmh_write_sleep_and_wake() - Writes the buffered wake and sleep sets + * to TCSes + * + * @dev: The device making the request + * + * Return: + * * 0 - Success + * * Error code - Otherwise + */ +int rpmh_write_sleep_and_wake(const struct device *dev) +{ + return rpmh_flush(get_rpmh_ctrlr(dev)); +} +EXPORT_SYMBOL(rpmh_write_sleep_and_wake); + +/** * rpmh_invalidate: Invalidate sleep and wake sets in batch_cache * * @dev: The device making the request diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index fa8bb53..59b68f8 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -22,6 +22,8 @@ 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_sleep_and_wake(const struct device *dev); + void rpmh_invalidate(const struct device *dev); #else @@ -43,6 +45,9 @@ static inline int rpmh_write_batch(const struct device *dev, static int rpmh_mode_solver_set(const struct device *dev, bool enable) { return -ENODEV; } +static int rpmh_write_sleep_and_wake(const struct device *dev) +{ return -ENODEV; } + static inline void rpmh_invalidate(const struct device *dev) { } From patchwork Mon Jan 25 06:20:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maulik Shah X-Patchwork-Id: 12042989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0CC83C433DB for ; Mon, 25 Jan 2021 06:43:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF2D2207B6 for ; Mon, 25 Jan 2021 06:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbhAYGmu (ORCPT ); Mon, 25 Jan 2021 01:42:50 -0500 Received: from a1.mail.mailgun.net ([198.61.254.60]:34409 "EHLO a1.mail.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbhAYGWJ (ORCPT ); Mon, 25 Jan 2021 01:22:09 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1611555689; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=A575rBuWWTIMOtrYPVjJaiHGzO6AU6bUAjGofeZOHKM=; b=ehFTHA2nBGMnvMOJbFKfeeLuIQClthyizMV0X3cD1WF+0/K186/oRm/ZY13ZVhzKrPO0c1ET xLVR8uRDBMLFiVdK1wD0bqmV9vG7elgsDZdPgCRP3R6DoLhr0Mon5Rbc34V4N0ir2lnfGxOc GiiWrKutxy2O15sOrjES/Z7PBEs= X-Mailgun-Sending-Ip: 198.61.254.60 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 600e6345fb02735e8c9e93a6 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 25 Jan 2021 06:20:53 GMT Sender: mkshah=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id AB59DC43461; Mon, 25 Jan 2021 06:20:52 +0000 (UTC) Received: from mkshah-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mkshah) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6C222C433ED; Mon, 25 Jan 2021 06:20:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6C222C433ED Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=mkshah@codeaurora.org From: Maulik Shah To: bjorn.andersson@linaro.org, agross@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, tkjos@google.com, dianders@chromium.org, ilina@codeaurora.org, lsrao@codeaurora.org, Maulik Shah Subject: [PATCH v2 3/3] soc: qcom: rpmh: Conditionally check lockdep_assert_irqs_disabled() Date: Mon, 25 Jan 2021 11:50:37 +0530 Message-Id: <1611555637-7688-3-git-send-email-mkshah@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org> References: <1611555637-7688-1-git-send-email-mkshah@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org lockdep_assert_irqs_disabled() was added to check rpmh_flush() can only be invoked when irqs are disabled from last CPU, this is true for APPS RSC as the last CPU going to deepest low power mode is writing sleep and wake TCSes. However platform drivers can invoke rpmh_write_sleep_and_wake() to immediately write cached sleep and wake sets to TCSes from any CPU. Conditionally check if rpmh_flush() is invoked from last CPU then do not check for irqs disabled as such RSCs can write sleep and wake TCSes at any point. Signed-off-by: Maulik Shah --- Changes in v2: - Update rpmh_flush() to show if its called from last CPU or not - Drop solver client flag as rpmh_flush() able to check if called from last CPU or not --- drivers/soc/qcom/rpmh-internal.h | 2 +- drivers/soc/qcom/rpmh-rsc.c | 3 ++- drivers/soc/qcom/rpmh.c | 23 +++++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 79486d6..f351780 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -136,6 +136,6 @@ void rpmh_rsc_invalidate(struct rsc_drv *drv); int rpmh_rsc_mode_solver_set(struct rsc_drv *drv, bool enable); void rpmh_tx_done(const struct tcs_request *msg, int r); -int rpmh_flush(struct rpmh_ctrlr *ctrlr); +int rpmh_flush(struct rpmh_ctrlr *ctrlr, bool from_last_cpu); #endif /* __RPM_INTERNAL_H__ */ diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index 1c1f5b0..a67bcd6 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -841,7 +841,8 @@ static int rpmh_rsc_cpu_pm_callback(struct notifier_block *nfb, * CPU. */ if (spin_trylock(&drv->lock)) { - if (rpmh_rsc_ctrlr_is_busy(drv) || rpmh_flush(&drv->client)) + if (rpmh_rsc_ctrlr_is_busy(drv) || + rpmh_flush(&drv->client, true)) ret = NOTIFY_BAD; spin_unlock(&drv->lock); } else { diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 725b8f0..682c566 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -458,22 +458,33 @@ static int send_single(struct rpmh_ctrlr *ctrlr, enum rpmh_state state, * rpmh_flush() - Flushes the buffered sleep and wake sets to TCSes * * @ctrlr: Controller making request to flush cached data + * @from_last_cpu: Set if invoked from last cpu with irqs disabled * * Return: * * 0 - Success * * Error code - Otherwise */ -int rpmh_flush(struct rpmh_ctrlr *ctrlr) +int rpmh_flush(struct rpmh_ctrlr *ctrlr, bool from_last_cpu) { struct cache_req *p; int ret = 0; - lockdep_assert_irqs_disabled(); + /* + * rpmh_flush() can be called when we think we're running + * on the last CPU with irqs_disabled or when RPMH client + * explicitly requests to write sleep and wake data. + * (for e.g. when in solver mode clients can requests to flush) + * + * Conditionally check for irqs_disabled only when called + * from last cpu. + */ + + if (from_last_cpu) + lockdep_assert_irqs_disabled(); /* - * Currently rpmh_flush() is only called when we think we're running - * on the last processor. If the lock is busy it means another - * processor is up and it's better to abort than spin. + * If the lock is busy it means another transaction is on going, + * in such case it's better to abort than spin. */ if (!spin_trylock(&ctrlr->cache_lock)) return -EBUSY; @@ -526,7 +537,7 @@ int rpmh_flush(struct rpmh_ctrlr *ctrlr) */ int rpmh_write_sleep_and_wake(const struct device *dev) { - return rpmh_flush(get_rpmh_ctrlr(dev)); + return rpmh_flush(get_rpmh_ctrlr(dev), false); } EXPORT_SYMBOL(rpmh_write_sleep_and_wake);