Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4286424imm; Mon, 8 Oct 2018 19:10:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV639EFsMx2hWqsLotieY2yoXmFNHrCC+DBlODgUn1p3NyCMv+iARM+N2F31BT53VenwmkIvE X-Received: by 2002:a62:9554:: with SMTP id p81-v6mr27830891pfd.222.1539051001182; Mon, 08 Oct 2018 19:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539051001; cv=none; d=google.com; s=arc-20160816; b=XwC8dplgpxFcvguYowzJVWm/iEjAsDxIRroT+PXQdWv7MmgtBGaHDoCICmcmHyL9a8 X02N8dQFHBojY+RKQhzGEinrJ5cp4UJv85jB40FM63ExmqkNUV469f0fMEVnrlR9v9dM SoW5eHcv38FYgZ9cCaj6jKE5coGaJrX3PWzU8SWWRZD3SkgL6iulvx1vtcDmkUjk4kV+ OhifqathTpCpGQV9Pyt5cpXLZ4t/ewYtol6I7/dJwhMMmWufm2DQ1bqsUulyvNBbo+8J ICgE/UBTcxHrAre3UAZg7wI26+w0/rpe3GgMauBBBWZukWJCcdBFJuvvcm2gIrRCt3Zm eTnw== 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; bh=QxMSDydizpLs1t3ePGTSP11Q6/lKSbnGxgmcGpTrBgc=; b=Z0vJAtzPBgk3enzgJgBHS+r/WRdF8HTODEoSp/l2+ZpAl/ISgRuMOJvj0ybTHV+KSU CsqExAGtAQwaJtTN55/0N0gg8naNmBAU3c0+ietPxcZtAgnUfjQB2/hKgDZekYHrmZlK iM9nwrRCf/CJJ5FhGSdeRpkKAh89hSzsjZAl5xI1YQbay1Q0tWUcBsoUGI4CWv+yBf4I eHo0lZYEBydVkBb7RwijfLXzJf5wP7vYMuKsMhNrYdomveH5IG20MhYOy4TM+aiuLzmC jlinzoCHpIr/MKtguNr4krLiD6QZqPMDtJhE3fLrzbauus5kYdZwqyod5vNYarDS7JnM 0NDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=IxeKBdtr; dkim=pass header.i=@codeaurora.org header.s=default header.b=PNV6I6m1; 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 a135-v6si24033553pfd.241.2018.10.08.19.09.47; Mon, 08 Oct 2018 19:10:01 -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=IxeKBdtr; dkim=pass header.i=@codeaurora.org header.s=default header.b=PNV6I6m1; 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 S1726989AbeJIJX2 (ORCPT + 99 others); Tue, 9 Oct 2018 05:23:28 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56560 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbeJIJX2 (ORCPT ); Tue, 9 Oct 2018 05:23:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0E3BD60C84; Tue, 9 Oct 2018 02:08:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539050933; bh=ii0PLJZPDD2k3fBLa82FHwLFjEOTs+24pTETEsLYFv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxeKBdtrlq0CQmOvV1g+OLtiuVCFyxm4SMqbrVFaFAtRWcZDaMbT8MQpfO9CznPIP IfPBtAVXpUIqiDXVL66x3Ly1V/Bfd3HkXIncMfl4TMjtmPt8l/tIrqsog5hGhL6VFG 4yMkuZZykd+RYcgkmcw4PJU9jQop+/2YvBGbR/dU= 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.2 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED,FROM_LOCAL_NOVOWEL 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 8A5B960C62; Tue, 9 Oct 2018 02:08:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539050932; bh=ii0PLJZPDD2k3fBLa82FHwLFjEOTs+24pTETEsLYFv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PNV6I6m17gb1i03sfU/TgTw+O3DLnLDPGMOEmauJY+uEpyTgNf4ZPBvn1d/FYIpAV o57MHxJE+vYAVN640NsQzH+zg+Ejezq7ERLGracshCirsTJi0zM9cntQmVA6FVVCzW Wnom4nHFKKVdZT+evv1qojCY6rbQN2ul9GyM9CcU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8A5B960C62 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, linux-pm@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 v3 2/3] drivers: qcom: rpmh-rsc: return if the controller is idle Date: Tue, 9 Oct 2018 07:38:31 +0530 Message-Id: <1539050912-25749-3-git-send-email-rplsssn@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539050912-25749-1-git-send-email-rplsssn@codeaurora.org> References: <1539050912-25749-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 Allow the controller status be queried. The controller is busy if it is actively processing request. Also 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 --- changes in v3 - Add lock check to avoid potential race as suggested by Matthias --- drivers/soc/qcom/rpmh-internal.h | 1 + drivers/soc/qcom/rpmh-rsc.c | 24 ++++++++++++++++++++++++ drivers/soc/qcom/rpmh.c | 13 +++++++++++++ include/soc/qcom/rpmh.h | 5 +++++ 4 files changed, 43 insertions(+) diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h index 2e3ffcd..4b891c23 100644 --- a/drivers/soc/qcom/rpmh-internal.h +++ b/drivers/soc/qcom/rpmh-internal.h @@ -109,6 +109,7 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg); int rpmh_rsc_invalidate(struct rsc_drv *drv); int rpmh_rsc_write_pdc_data(struct rsc_drv *drv, const struct tcs_request *msg); +bool rpmh_rsc_ctrlr_is_idle(struct rsc_drv *drv); void rpmh_tx_done(const struct tcs_request *msg, int r); #endif /* __RPM_INTERNAL_H__ */ diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c index d6b834e..9cc303e 100644 --- a/drivers/soc/qcom/rpmh-rsc.c +++ b/drivers/soc/qcom/rpmh-rsc.c @@ -525,6 +525,30 @@ 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); + + spin_lock(&drv->lock); + for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { + if (!tcs_is_free(drv, m)) { + spin_unlock(&drv->lock); + return false; + } + } + spin_unlock(&drv->lock); + + return true; +} + +/** * rpmh_rsc_write_ctrl_data: Write request to the controller * * @drv: the controller diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 297d6cc..43eb981 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -535,3 +535,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 b05e31a..4c4b013 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -27,6 +27,8 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state, int rpmh_write_pdc_data(const struct device *dev, const struct tcs_cmd *cmd, u32 n); +int rpmh_ctrlr_idle(const struct device *dev); + #else static inline int rpmh_write(const struct device *dev, enum rpmh_state state, @@ -53,6 +55,9 @@ static inline int rpmh_write_pdc_data(const struct device *dev, const struct tcs_cmd *cmd, u32 n) { return -ENODEV; } +static inline int rpmh_ctrlr_idle(const struct device *dev) +{ return -ENODEV; } + #endif /* CONFIG_QCOM_RPMH */ #endif /* __SOC_QCOM_RPMH_H__ */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation.