Received: by 10.192.165.148 with SMTP id m20csp26169imm; Thu, 19 Apr 2018 15:19:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx49h/5g7+q900ZWs+fHN7OyD95/D6pgJRiTqYfdbUPw7iq89p96tmf/oJhPlI7HEP2mKEM1Y X-Received: by 10.101.90.129 with SMTP id c1mr6528076pgt.20.1524176375181; Thu, 19 Apr 2018 15:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524176375; cv=none; d=google.com; s=arc-20160816; b=RC2fJwRn5i9KUWsmZxd6hnkUIw/2ics6gWFxXAmR5PuVJ52QMFG07QjMma4AJJGi+m JtQvxjIThBiwXjoBGmYYldGpGZO0SeMOtF6ikapzi6q75DOfHGHuzMxwo/lwlszAhfrM +rtKagPsF3gloFY8tr33gsKkqYLyMbK2IKpnrPFRmzknwmIEgWUp1tkUWcyNKeRR3zUR +xFk7U87DxamVkRATS7ukWH4XzU7/u3lpl2l7ivgU4VTC85JxbKlxu4q1svd7hlCI2iW y6ATaM0NNWG4wgdxOeW3i+b5skJDbtFJeyw2/KRdij99CsoYaGg5uxdy0QBFYEm4U8R2 ISkw== 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=MCBR2DN5Ja1hf8jnKf8AdbUTJgd5Cg+UiLAG5CusCus=; b=TBV1/8SdocYmVQ5sBLYCnQo0ZL+2jvHHRDKuRJnDeLTddXykKk5nXzoMjluzwhPW8d ovH4FhPumo2aCmP8G7U4mI+MTREmZ8RAOYA0uPLiO64e+2eBuRuOma21lrDrAMeYReav VtLQO40qStw9t8YqJup5DrKE7+/X3Nmf3/r7e2fickmcY1aTuWcoEIG/viAVOnWtglhz tGVOv6HVfTa8FWXl0c5Kwut4rg1fwxRVsviUhiG1Ibsu5q1z230a9dFCDnJK8h2Y/je+ WAExINPBBAdjNOgVvyZXjQXV3npJSF8U4bP0ZOSJ48mHJsI+XeqbkiiQjuUP5dDsxr/W AwKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GMt0UK0M; dkim=pass header.i=@codeaurora.org header.s=default header.b=g+jjVYjs; 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 a5-v6si2635525pla.117.2018.04.19.15.19.21; Thu, 19 Apr 2018 15:19:35 -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=GMt0UK0M; dkim=pass header.i=@codeaurora.org header.s=default header.b=g+jjVYjs; 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 S1753992AbeDSWRr (ORCPT + 99 others); Thu, 19 Apr 2018 18:17:47 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57764 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753928AbeDSWRA (ORCPT ); Thu, 19 Apr 2018 18:17:00 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AF9386081C; Thu, 19 Apr 2018 22:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524176220; bh=RVBgAE2i+A+k7wzn6+EMktcby9vVZQwZvbfI6TS8nMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GMt0UK0MWdrZVVJuGCD4TRh6KiKfLvRzNMg0qOLlp14oECI4z5BuXAkjrfBHbKemG HJ3MNcG3RfpzN5gJaMLM+24UT+6Nh5E3H92yIfofS/hN/ACawqAVG72fOdVUkJJP+o eKF72jIf3DHPB8QHV4DrkchQhehBobH5Hsnbb+L8= 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 6380460FFA; Thu, 19 Apr 2018 22:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524176213; bh=RVBgAE2i+A+k7wzn6+EMktcby9vVZQwZvbfI6TS8nMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g+jjVYjsAHU2Yyzlk2rwpPz0JDXc6HyeE+q+pQwSr9+Bgbj7bAdI8fyCwXONHT6J/ Sctuh/RMKAcfKTlXgZjgGvZaDSlnMLWVxym2gluwfjyDx7Z21znQsV19mVV7fpHNp1 E1ZTCHM3MHajdQ8gsj0nm+0LCFWR8qQiBPu1ykho= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6380460FFA 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 v6 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Date: Thu, 19 Apr 2018 16:16:33 -0600 Message-Id: <20180419221635.17849-9-ilina@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180419221635.17849-1-ilina@codeaurora.org> References: <20180419221635.17849-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 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