LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Lina Iyer <ilina@codeaurora.org>
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 <ilina@codeaurora.org>
Subject: [PATCH v6 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously
Date: Thu, 19 Apr 2018 16:16:33 -0600 [thread overview]
Message-ID: <20180419221635.17849-9-ilina@codeaurora.org> (raw)
In-Reply-To: <20180419221635.17849-1-ilina@codeaurora.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 <ilina@codeaurora.org>
---
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 c4cf78381dde..b56445a05e23 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;
};
/**
@@ -129,6 +132,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);
@@ -240,6 +245,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
next prev parent reply other threads:[~2018-04-19 22:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-19 22:16 [PATCH v6 00/10] drivers/qcom: add RPMH communication support Lina Iyer
2018-04-19 22:16 ` [PATCH v6 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs Lina Iyer
2018-04-19 22:16 ` [PATCH v6 02/10] dt-bindings: introduce RPMH RSC bindings for Qualcomm SoCs Lina Iyer
2018-05-01 23:45 ` Doug Anderson
2018-05-02 14:56 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 03/10] drivers: qcom: rpmh-rsc: log RPMH requests in FTRACE Lina Iyer
2018-04-19 22:16 ` [PATCH v6 04/10] drivers: qcom: rpmh: add RPMH helper functions Lina Iyer
2018-04-26 18:05 ` Matthias Kaehlcke
2018-04-27 16:55 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS Lina Iyer
2018-04-25 21:41 ` Matthias Kaehlcke
2018-04-27 17:39 ` Lina Iyer
2018-04-27 18:40 ` Matthias Kaehlcke
2018-04-27 19:45 ` Lina Iyer
2018-04-27 20:06 ` Matthias Kaehlcke
2018-04-27 21:32 ` Lina Iyer
2018-04-27 21:54 ` Matthias Kaehlcke
2018-04-27 23:24 ` Doug Anderson
2018-05-01 16:10 ` Lina Iyer
2018-05-01 16:42 ` Doug Anderson
2018-05-01 17:35 ` Lina Iyer
2018-05-01 16:45 ` Matthias Kaehlcke
2018-04-19 22:16 ` [PATCH v6 06/10] drivers: qcom: rpmh-rsc: allow invalidation of sleep/wake TCS Lina Iyer
2018-04-25 22:11 ` Matthias Kaehlcke
2018-04-27 16:44 ` Lina Iyer
2018-04-27 16:54 ` Matthias Kaehlcke
2018-04-19 22:16 ` [PATCH v6 07/10] drivers: qcom: rpmh: cache sleep/wake state requests Lina Iyer
2018-04-19 22:16 ` Lina Iyer [this message]
2018-04-19 22:16 ` [PATCH v6 09/10] drivers: qcom: rpmh: add support for batch RPMH request Lina Iyer
2018-04-25 23:41 ` Matthias Kaehlcke
2018-04-27 16:24 ` Lina Iyer
2018-04-19 22:16 ` [PATCH v6 10/10] drivers: qcom: rpmh-rsc: allow active requests from wake TCS Lina Iyer
2018-04-26 1:14 ` Matthias Kaehlcke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180419221635.17849-9-ilina@codeaurora.org \
--to=ilina@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=david.brown@linaro.org \
--cc=dianders@chromium.org \
--cc=evgreen@chromium.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=rnayak@codeaurora.org \
--cc=sboyd@kernel.org \
--subject='Re: [PATCH v6 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).