Received: by 10.192.165.148 with SMTP id m20csp4493515imm; Tue, 8 May 2018 09:17:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr47YAda7W673rEvvkUl/1arS2nJkXz10E5ps+wOL9PNy5aozYuLID9ok4sm09+gCs3Qaz5 X-Received: by 2002:a17:902:d882:: with SMTP id b2-v6mr9901462plz.220.1525796231196; Tue, 08 May 2018 09:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525796231; cv=none; d=google.com; s=arc-20160816; b=dNlmJ5j+IDMA6/XhYoHdz3iZA1yX+4mzXCW0hamd3bh5HN+SlXdn6TjSxm1P736X+a yPveuW/JElLsUqc+m5eTEXObJ65XdjAVTPIpm1C/CM0e7HtfWpNUwFBnm0xZFR6igWx0 1DLt/yb0T3ww+kg1dicrWMDeea3pn7h5BAZ2nw2vS/sFHFyMoUv8OpoqcvBpl5G1yuj/ hQXwlkemYrFsbJMqziX4RiRMobc7ssH+CNf2x7AAlPkkWfHLhHLOWbEVGTlqgkdjj0K8 ftQs/qe1EHdNSDACiYF1MFvXDgGOZqpt/KPeJa+Ux9Gnvu+Jq4eBSejiR2XPDoU47HPd uHNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=1RaWAadtfNoouVA1/qvcOKTXrBFcPXIPTK7iZ469KyM=; b=LwC3YWHF6b6Zt7HdnR4rLZHEslBCdA9lGY9OodVB+HPFD9MQo6ra1DiwOStm0Ql4kP 2/NHEbopDcnTJ7ruKmRj8UtXCKzNichNUt3zmQaA9qmovqd0A1CHTDj0mhuV8RfsBWfe cgwIJSlN+eW5feR4MsGL1OaR3fDj0Ob6NG1quuGzoSpZ5wx207MW3vOA+D4yVmJppJbP aJHoGBconZh8Lm+0kA80peZPlHdvJqSAXM/V4LoW9oU81XEjZKnoijCjWNfgiVokoDdn xSg+7re6Cxy8cvV7exoQ2j6gnECrmUX4rI72HjFWZID5YwgMM4F7KsnegvFn/MAHpK5e NzoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=RyjlyXK3; dkim=pass header.i=@codeaurora.org header.s=default header.b=K+aii7rL; 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 j123si25667500pfd.207.2018.05.08.09.16.56; Tue, 08 May 2018 09:17:11 -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=RyjlyXK3; dkim=pass header.i=@codeaurora.org header.s=default header.b=K+aii7rL; 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 S1754521AbeEHQQT (ORCPT + 99 others); Tue, 8 May 2018 12:16:19 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46198 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751806AbeEHQQR (ORCPT ); Tue, 8 May 2018 12:16:17 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0F2F76085F; Tue, 8 May 2018 16:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525796177; bh=V2ZQ/dgYnhhndzI9lUTSBBpCevcJc43meKKlOB9AG4I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RyjlyXK3H4Z4IOapQYqnShcgt8PziYVG0sV4Q3I4A+fBu2YHiCkD9d9iEoaikhpm3 3sVauzAiHf5Yz4mT7ODUJL5cHrpX2pxyQwhJT4SlNKKbtsahK8ZzrFT14HsxrH13+Y cRKVlHQPH1V9LTU9EuuzlJ2xv7a9xKK6lc+/qH2s= 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 mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 77E7C60767; Tue, 8 May 2018 16:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525796176; bh=V2ZQ/dgYnhhndzI9lUTSBBpCevcJc43meKKlOB9AG4I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=K+aii7rLw+04gw2b9ky1i4b7ZwGlGENC0rQZo+NMMtqdpu/4peNUkzug88Or9j3Vm 50MSAyjVsPK291KVEhSWj+04mxLRAsEAnQemMuihGdAyUmLhyCkK1bLjkihA+FjQcO gqd2EHLCQztskv3rJfqLD4/9PirmS3Qw3lBHRsmk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 08 May 2018 10:16:16 -0600 From: ilina@codeaurora.org To: Matthias Kaehlcke Cc: andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, sboyd@kernel.org, evgreen@chromium.org, dianders@chromium.org Subject: Re: [PATCH v7 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS In-Reply-To: <20180503213539.GA19594@google.com> References: <20180502193749.31004-1-ilina@codeaurora.org> <20180502193749.31004-6-ilina@codeaurora.org> <20180503213539.GA19594@google.com> Message-ID: <462ea6c6f62f5480f17ce7bf81ff5db1@codeaurora.org> X-Sender: ilina@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-03 15:35, Matthias Kaehlcke wrote: > Hi Lina, > > On Wed, May 02, 2018 at 01:37:44PM -0600, Lina Iyer wrote: >> Sleep and wake requests are sent when the application processor >> subsystem of the SoC is entering deep sleep states like in suspend. >> These requests help lower the system power requirements when the >> resources are not in use. >> >> Sleep and wake requests are written to the TCS slots but are not >> triggered at the time of writing. The TCS are triggered by the >> firmware >> after the last of the CPUs has executed its WFI. Since these requests >> may come in different batches of requests, it is the job of this >> controller driver to find and arrange the requests into the available >> TCSes. >> >> Signed-off-by: Lina Iyer >> Reviewed-by: Evan Green >> >> --- >> >> Changes in v7: >> - Bug fix in find_match() >> --- >> drivers/soc/qcom/rpmh-internal.h | 8 +++ >> drivers/soc/qcom/rpmh-rsc.c | 118 >> +++++++++++++++++++++++++++++++ >> 2 files changed, 126 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmh-internal.h >> b/drivers/soc/qcom/rpmh-internal.h >> index d9a21726e568..6e19fe458c31 100644 >> --- a/drivers/soc/qcom/rpmh-internal.h >> +++ b/drivers/soc/qcom/rpmh-internal.h >> @@ -14,6 +14,7 @@ >> #define MAX_CMDS_PER_TCS 16 >> #define MAX_TCS_PER_TYPE 3 >> #define MAX_TCS_NR (MAX_TCS_PER_TYPE * TCS_TYPE_NR) >> +#define MAX_TCS_SLOTS (MAX_CMDS_PER_TCS * MAX_TCS_PER_TYPE) >> #define RPMH_MAX_CTRLR 2 >> >> struct rsc_drv; >> @@ -30,6 +31,8 @@ struct rsc_drv; >> * @ncpt: number of commands in each TCS >> * @lock: lock for synchronizing this TCS writes >> * @req: requests that are sent from the TCS >> + * @cmd_cache: flattened cache of cmds in sleep/wake TCS >> + * @slots: indicates which of @cmd_addr are occupied >> */ >> struct tcs_group { >> struct rsc_drv *drv; >> @@ -40,6 +43,8 @@ struct tcs_group { >> int ncpt; >> spinlock_t lock; >> const struct tcs_request *req[MAX_TCS_PER_TYPE]; >> + u32 *cmd_cache; >> + DECLARE_BITMAP(slots, MAX_TCS_SLOTS); >> }; >> >> /** >> @@ -69,6 +74,9 @@ struct rsc_drv { >> extern struct list_head rsc_drv_list; >> >> int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request >> *msg); >> +int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, >> + const struct tcs_request *msg); >> +int rpmh_rsc_invalidate(struct rsc_drv *drv); >> >> void rpmh_tx_done(const struct tcs_request *msg, int r); >> >> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c >> index 33270b1d5991..4e2144a14c31 100644 >> --- a/drivers/soc/qcom/rpmh-rsc.c >> +++ b/drivers/soc/qcom/rpmh-rsc.c >> @@ -113,6 +113,12 @@ static struct tcs_group *get_tcs_for_msg(struct >> rsc_drv *drv, >> case RPMH_ACTIVE_ONLY_STATE: >> type = ACTIVE_TCS; >> break; >> + case RPMH_WAKE_ONLY_STATE: >> + type = WAKE_TCS; >> + break; >> + case RPMH_SLEEP_STATE: >> + type = SLEEP_TCS; >> + break; >> default: >> return ERR_PTR(-EINVAL); >> } >> @@ -353,6 +359,105 @@ int rpmh_rsc_send_data(struct rsc_drv *drv, >> const struct tcs_request *msg) >> } >> EXPORT_SYMBOL(rpmh_rsc_send_data); >> >> +static int find_match(const struct tcs_group *tcs, const struct >> tcs_cmd *cmd, >> + int len) >> +{ >> + int i, j; >> + >> + /* Check for already cached commands */ >> + for_each_set_bit(i, tcs->slots, MAX_TCS_SLOTS) { >> + if (tcs->cmd_cache[i] != cmd[0].addr) >> + continue; >> + for (j = 0; j < len; j++) { >> + if (tcs->cmd_cache[i + j] != cmd[j].addr) { > > As mentioned in the review of v6, the code could read memory beyond > tcs->cmd_cache if 'i + len > ARRAY_SIZE(tcs->cmd_cache)' > Ok. Will add it. >> + WARN(1, "Message does not match previous sequence.\n"); >> + return -EINVAL; >> + } >> + } >> + return i; >> + } >> + >> + return -ENODATA; >> +} >> + >> +static int find_slots(struct tcs_group *tcs, const struct tcs_request >> *msg, >> + int *tcs_id, int *cmd_id) > > The change from m/n => tcs_id/cmd_id in v7 greatly improves > readability, thanks! > > Matthias > > PS: Please remember to include reviewers of earlier revisions to cc: Sure. Thanks, Lina