Received: by 10.192.165.148 with SMTP id m20csp1018978imm; Wed, 2 May 2018 12:39:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrXA1CHAY3pk1113Q2RFhzl5MtQ8ccPN8gn1JcCWEUGiIEyV0CQcpAvWTcreSmhwBCS19D+ X-Received: by 2002:a63:7405:: with SMTP id p5-v6mr12055732pgc.289.1525289999688; Wed, 02 May 2018 12:39:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525289999; cv=none; d=google.com; s=arc-20160816; b=W+Ha6CAa8CXOT0nsIDWYgBVARowRKx4MZByryU06SM5cNytBN1pLML9c4AmoHpPqYJ xIomRsIrWwIa4zdcum5Eno1pFVHAzkLun5UP/ViqnSRe+Ysc2qbYVCsBq5Cw6n1d7EGQ gZu/zJfvd/W4xoc2+BXVUmTNN9023BTEAXMo7D+iz2boEaMBl17zp4SLv5d0WIOclkwW qszd8od+hBvOY42mXc/f+YZMQs46Ag9shJ+AFvSi1S7apLdUhfUT8j5BVNgUZYixkx7v AJOKWrilwTh04t+dJkamjT7F/Bis6AikJbYmu5A0WDzGo1GE7anL2Ql+D/PaVKO2GYKx Jdsw== 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=RKv3vkwWSr35cdwQn/xaXFuXHeRsSucZx/uNtAyoha4=; b=mQQ7mojZOXQwr1a3TTsIL9aqAu4VIx8CWOcF5d8JgjCACK43VzdUlueyzUT5k69u8e sGC7Tiq/TfS8EaTGSsr/KhJ0GVS19nGITCFefne5Lz1NRelxnVLo5K8XJtNg//XJNYia CuqBNUFdzLPXl4ELCqs8I5l4pnZloE8wsZybBNHXCsIyfYbuRLMwwdKs0m2EPbSHjshA /Zm6xMzoW0ULYPB/ZDddd3RRIKAgnMluVl6X4sddEqZBueSkt9kehcdf5VQ8rCBgcKzp vfg+NPtWpXl50JbyavXahDZTSSeSkXPf2nLG/iqAZHUlsHQF78bwgFxb6MmqRiU55Uy5 a6jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=HOjc9zRf; dkim=pass header.i=@codeaurora.org header.s=default header.b=QNlLsXg+; 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 l129-v6si10045474pgl.485.2018.05.02.12.39.45; Wed, 02 May 2018 12:39:59 -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=HOjc9zRf; dkim=pass header.i=@codeaurora.org header.s=default header.b=QNlLsXg+; 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 S1751528AbeEBTiw (ORCPT + 99 others); Wed, 2 May 2018 15:38:52 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:38758 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751350AbeEBTiG (ORCPT ); Wed, 2 May 2018 15:38:06 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1E4A86079C; Wed, 2 May 2018 19:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525289886; bh=vtMvPJ+QUNBnAhjwkZWlL0AWZztzfoHhu8LgkthanKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOjc9zRf4+1XaXGXXsLf/JqxDyYb4aZzIwHAtub2e5q0yGyqDQWslghqTIe2Jhs14 moXrYEfy2DMXXjxGK95jYl8WDNmOSVuq+ZvuFHgAeXzAct6zTBQkft/Mr2QKRrjEVF xyZWrPRQGaAlA5mWOjXfmaDL9VxgNBTL8Ga6XYUQ= 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.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from codeaurora.org (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7F9C7607CF; Wed, 2 May 2018 19:38:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525289885; bh=vtMvPJ+QUNBnAhjwkZWlL0AWZztzfoHhu8LgkthanKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QNlLsXg+u+dWcVXd2hmzma2f8CF4YgGMh+tII6yYJw3iap6pnlNf+52KDvIaAiQo3 FiYIVb03TAOlgYHD5kixXkdi1J9KVynYGK3raT8/f7wW7SeYZPluOdPz4kBJTdRUqU jxltlvI3l/6use5QSFdpSLNMVJsAST5L3CcYV3q4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7F9C7607CF 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=ilina@codeaurora.org From: Lina Iyer 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, Lina Iyer Subject: [PATCH v7 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Date: Wed, 2 May 2018 13:37:47 -0600 Message-Id: <20180502193749.31004-9-ilina@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180502193749.31004-1-ilina@codeaurora.org> References: <20180502193749.31004-1-ilina@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Platform drivers that want to send a request but do not want to block until the RPMH request completes have now a new API - rpmh_write_async(). The API allocates memory and send the requests and returns the control back to the platform driver. The tx_done callback from the controller is handled in the context of the controller's thread and frees the allocated memory. This API allows RPMH requests from atomic contexts as well. Signed-off-by: Lina Iyer --- Changes in v6: - replace rpmh_client with device * --- drivers/soc/qcom/rpmh.c | 52 +++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/rpmh.h | 7 ++++++ 2 files changed, 59 insertions(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index 23fcbd9487cd..1bb62876795c 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -33,6 +33,7 @@ .cmd = { { 0 } }, \ .completion = q, \ .dev = dev, \ + .free = NULL, \ } /** @@ -58,6 +59,7 @@ struct cache_req { * @completion: triggered when request is done * @dev: the device making the request * @err: err return from the controller + * @free: the request object to be freed at tx_done */ struct rpmh_request { struct tcs_request msg; @@ -65,6 +67,7 @@ struct rpmh_request { struct completion *completion; const struct device *dev; int err; + struct rpmh_request *free; }; /** @@ -137,6 +140,8 @@ void rpmh_tx_done(const struct tcs_request *msg, int r) dev_err(rpm_msg->dev, "RPMH TX fail in msg addr=%#x, err=%d\n", rpm_msg->msg.cmds[0].addr, r); + kfree(rpm_msg->free); + /* Signal the blocking thread we are done */ if (compl) complete(compl); @@ -248,6 +253,53 @@ static int __rpmh_write(const struct device *dev, enum rpmh_state state, return ret; } +static struct rpmh_request *__get_rpmh_msg_async(enum rpmh_state state, + const struct tcs_cmd *cmd, + u32 n) +{ + struct rpmh_request *req; + + if (!cmd || !n || n > MAX_RPMH_PAYLOAD) + return ERR_PTR(-EINVAL); + + req = kzalloc(sizeof(*req), GFP_ATOMIC); + if (!req) + return ERR_PTR(-ENOMEM); + + memcpy(req->cmd, cmd, n * sizeof(*cmd)); + + req->msg.state = state; + req->msg.cmds = req->cmd; + req->msg.num_cmds = n; + req->free = req; + + return req; +} + +/** + * rpmh_write_async: Write a set of RPMH commands + * + * @dev: The device making the request + * @state: Active/sleep set + * @cmd: The payload data + * @n: The number of elements in payload + * + * Write a set of RPMH commands, the order of commands is maintained + * and will be sent as a single shot. + */ +int rpmh_write_async(const struct device *dev, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ + struct rpmh_request *rpm_msg; + + rpm_msg = __get_rpmh_msg_async(state, cmd, n); + if (IS_ERR(rpm_msg)) + return PTR_ERR(rpm_msg); + + return __rpmh_write(dev, state, rpm_msg); +} +EXPORT_SYMBOL(rpmh_write_async); + /** * rpmh_write: Write a set of RPMH commands and block until response * diff --git a/include/soc/qcom/rpmh.h b/include/soc/qcom/rpmh.h index 42e62a0d26d8..1161a5c77e75 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -14,6 +14,9 @@ int rpmh_write(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n); +int rpmh_write_async(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); @@ -24,6 +27,10 @@ static inline int rpmh_write(const struct device *dev, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n) { return -ENODEV; } +static inline int rpmh_write_async(const struct device *dev, + enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ return -ENODEV; } static inline int rpmh_flush(const struct device *dev) { return -ENODEV; } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project