Received: by 10.213.65.68 with SMTP id h4csp2125201imn; Thu, 5 Apr 2018 09:22:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+pU9/so26/4zafhogh7ip4DCZZq73e0HgjSQZHm7//M07WLdhnPw3Va+PcmuKxOMbFwo1d X-Received: by 10.101.70.132 with SMTP id h4mr15196940pgr.155.1522945323408; Thu, 05 Apr 2018 09:22:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522945323; cv=none; d=google.com; s=arc-20160816; b=COFNNiRUZHG7Z7hOSK9y64Bm8/u5pOwAl8b9x4I29Ralt/RLcF2o3SPmX7NHf6kmZ7 u6mp8Q8yHJT8HN6T19ofI+1LcOZOpZhfcFOVcxkXcTcc5FueOExbrQ1jQkOTWsyZyIj4 NljCw9qo6J0KLjYgV8Vio5mXAiGBMNoy5mnNPuTjbMRvMZVENvPTOog01ty7mHuTsTmQ vlJvSdtr9rdjsV8NisvO6qnveljjwuUXTQZopDAsrcJUDMMOhrt5+poI7eaXHhvGbH2N h4dYRDlL+7nho1LiqWecPQeg2s4XsJRfavEHq7fFELk347jUhpEfZ3IewkV+ffAt8c02 rHhw== 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=Vkubz6w8sH2w4ZfetXDCnDI3phZB5muJ40ZKOHi2mAg=; b=ntvai2vvZVa2ZAMtq4MSgRFbQW2+Mbymanf/P6uU0EBrMAcVDA2IPlz0wArAajmFsK 7ai8ciDe/jH0Il29Ncak9wkICDYxJXq3td0+/3nGIF0YsClyeu7svJ4UavAVH84TLNuW +76Q8AskZPkEItUSlnxV81cf/mbhRsp96wXhia6zzKXyU9ll6zAb9zP824u8BCIIjugS NxSgY+bSIP9DBmtIOnhephcgWrROItoVOnzBWzCr4zzEnAwDHhFmrgOGOfQlrgNAg6rl 9BhoRMZ1bJhedHLcxxEsJFJOy5Zn/Phlb9ipAGWR0X/T4UDT8TcsZia+mQKNoVvSDoLO 6mdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=VGM0jQzX; dkim=pass header.i=@codeaurora.org header.s=default header.b=Tvedt4h3; 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 g61-v6si6087546plb.686.2018.04.05.09.21.48; Thu, 05 Apr 2018 09:22:03 -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=VGM0jQzX; dkim=pass header.i=@codeaurora.org header.s=default header.b=Tvedt4h3; 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 S1751603AbeDEQTw (ORCPT + 99 others); Thu, 5 Apr 2018 12:19:52 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41918 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbeDEQSy (ORCPT ); Thu, 5 Apr 2018 12:18:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A3BF960850; Thu, 5 Apr 2018 16:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522945134; bh=g+97MGUCxFLlDIs0Q8rbk+kl2Ixuu+ggKFtmOSS6QbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VGM0jQzX234JfPjvXn2mwIL/ADIJWwyxchI1ISMPRQPMYezJkcmLV+8YvzsOrGxA3 peFRMGImZsvXREuu0EeUezo08T98FrvmEdVfJ0q4m0g4ZgKzNGcW20YlZfXSODi9nN Eod9EUJQQuqkGBk8GxcieNjhJ+nQpbfLI2PIlXZs= 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 6D3D260F94; Thu, 5 Apr 2018 16:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522945130; bh=g+97MGUCxFLlDIs0Q8rbk+kl2Ixuu+ggKFtmOSS6QbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tvedt4h3JAAc6F3KGY2YgTGbFxO/eQwhyg1RlYbpYLE21osB73NEIwHRUnTqNVQfi n0iwBEAzJBlZKrDbt9GLLiAZ8C+e6TTPm9Ls+J/w0gN30l1hrgn7X3n1ldikMkFFg+ MUZXxa0Y6dX8bzpO/yFB5JXrEiVkQiP7HOFuWjHA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6D3D260F94 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 v5 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Date: Thu, 5 Apr 2018 10:18:32 -0600 Message-Id: <20180405161834.3850-9-ilina@codeaurora.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180405161834.3850-1-ilina@codeaurora.org> References: <20180405161834.3850-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 --- drivers/soc/qcom/rpmh.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/rpmh.h | 8 ++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c index b5468ef082c1..3a96e5f58302 100644 --- a/drivers/soc/qcom/rpmh.c +++ b/drivers/soc/qcom/rpmh.c @@ -35,6 +35,7 @@ .cmd = { { 0 } }, \ .completion = q, \ .rc = rc, \ + .free = NULL, \ } /** @@ -59,6 +60,7 @@ struct cache_req { * @cmd: the payload that will be part of the @msg * @completion: triggered when request is done * @err: err return from the controller + * @free: the request object to be freed at tx_done */ struct rpmh_request { struct tcs_request msg; @@ -66,6 +68,7 @@ struct rpmh_request { struct completion *completion; struct rpmh_client *rc; int err; + struct rpmh_request *free; }; /** @@ -110,6 +113,8 @@ void rpmh_tx_done(const struct tcs_request *msg, int r) "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); @@ -255,6 +260,54 @@ static int __rpmh_write(struct rpmh_client *rc, enum rpmh_state state, return ret; } +static struct rpmh_request *__get_rpmh_msg_async(struct rpmh_client *rc, + enum rpmh_state state, + const struct tcs_cmd *cmd, + u32 n) +{ + struct rpmh_request *req; + + if (IS_ERR_OR_NULL(rc) || !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 + * + * @rc: The RPMh handle got from rpmh_get_client + * @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(struct rpmh_client *rc, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ + struct rpmh_request *rpm_msg; + + rpm_msg = __get_rpmh_msg_async(rc, state, cmd, n); + if (IS_ERR(rpm_msg)) + return PTR_ERR(rpm_msg); + + return __rpmh_write(rc, 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 41a2518c46a5..9e6de09e43f0 100644 --- a/include/soc/qcom/rpmh.h +++ b/include/soc/qcom/rpmh.h @@ -15,6 +15,9 @@ struct rpmh_client; int rpmh_write(struct rpmh_client *rc, enum rpmh_state state, const struct tcs_cmd *cmd, u32 n); +int rpmh_write_async(struct rpmh_client *rc, enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n); + struct rpmh_client *rpmh_get_client(struct platform_device *pdev); int rpmh_flush(struct rpmh_client *rc); @@ -32,6 +35,11 @@ static inline int rpmh_write(struct rpmh_client *rc, enum rpmh_state state, static inline struct rpmh_client *rpmh_get_client(struct platform_device *pdev) { return ERR_PTR(-ENODEV); } +static inline int rpmh_write_async(struct rpmh_client *rc, + enum rpmh_state state, + const struct tcs_cmd *cmd, u32 n) +{ return -ENODEV; } + static inline int rpmh_flush(struct rpmh_client *rc) { return -ENODEV; } -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project