Received: by 10.192.165.148 with SMTP id m20csp471214imm; Wed, 9 May 2018 16:26:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrYl5dhxKnavQ2MOjTikRz/wzTG1JpVmvRTDVIkfatLNrtRb5h/ksUmDOC2BKBGGS3nyXe4 X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr28145495plk.101.1525908410530; Wed, 09 May 2018 16:26:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525908410; cv=none; d=google.com; s=arc-20160816; b=u7bxT5kE4InZFFU57Xnh7VASKpsHcjzRHjX/Yeoi0xJh5mSxRGzK31mkabS8wxRx1c hdKQHfV3uTH7gjaVaGsesW9Sgz3jsSuGQHvrKzqk8/cYpDXm+eaG5d0uXXnFVcX1wxNQ d32QP54Gxsb5jMHLczhJdAH1OzRX602+r3pgqTuFhemynjCv3wm+5ij0NsU9LoQ9dWLZ E4nSrQ0jmGgLLVWpfOn412GnNZsvfb/SgAjWw9unGE5isgm5OGhT0Uf7KkejZsbvBt29 l1FujA8OebcdSpLntrn+1Kh9ymhELxy3Njo5quDaZ2o0AMYPOuvViBC8XbnB3nI+IfMp Ye2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=i3hjbqy9rpWwNq8Do2oNnN6HtDzokZWCOwpcqa1nuSw=; b=MKgHnfykxUUTGjDgUCVTU76ByBxQ1H4arIoiFXAKfE2Q3Sjh/p+OMpUoeNlKNrAPW1 zMNw36kwQlZg0XZaWd1qzEHYF7UIZiUqL0mMpos5BT58WoT35nQ/96UdTeeNCLIfCDgv NAtd3rZI2EX+bt/Qbk+bV6abpOm6ZowX5l1t2y1BiljGnfAkrzokPEe1ywAgZYIyjqat uXjg8TMvK5roKn/eGzO9mvuGJlZ1ZF3CsW4ZIFodrW73Lnw9OMFGWnzjH7uIV9RRuSz9 BXPkNnvyhXTBoIsI+5fTrsXWlgr8FqaQctHc43G+cBOXdp32ibUxmiwkGcSmSK7ABlBG THAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=i82jgHJ6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66-v6si243340pgc.466.2018.05.09.16.26.35; Wed, 09 May 2018 16:26:50 -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=@chromium.org header.s=google header.b=i82jgHJ6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966005AbeEIXZH (ORCPT + 99 others); Wed, 9 May 2018 19:25:07 -0400 Received: from mail-pl0-f45.google.com ([209.85.160.45]:35026 "EHLO mail-pl0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965949AbeEIXZF (ORCPT ); Wed, 9 May 2018 19:25:05 -0400 Received: by mail-pl0-f45.google.com with SMTP id i5-v6so149411plt.2 for ; Wed, 09 May 2018 16:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=i3hjbqy9rpWwNq8Do2oNnN6HtDzokZWCOwpcqa1nuSw=; b=i82jgHJ6Fr+UvqYgLmI/jbOOOwJQXkbOq93k0M/uL5mUJpiHaj0Zu3f1shcDhoDvmg D1OdonCEFX3bPLA5QNqMIEMt16iDbaZ0Ree0FWBhI7quBlXRGbwnZ4WUXUHSz5SVIPUP Uwsg09/WcH3AYTwTJ3zLHkbreVWp1cAP3po2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=i3hjbqy9rpWwNq8Do2oNnN6HtDzokZWCOwpcqa1nuSw=; b=mXz6VJj2lFFSo+emflLVb2c+ZH3px6c7MjdpOBz31NDTpGh0mFXxNrjirjiC60BWV4 8iuGtT+dth7xHs6GUrhYIJ/8b6pju0adZIb5gU8jq1RIEM7VH2z6+GSvXgek8+HkkOAQ 3ftKguXhF1IN1jjrQFe194yLh1dAbXCvlt7Ob8Cbe4aoBgIc+y3MnDo/xja/3a64bvyZ Jg2KebIIeooo3HJzS0YxjKj1PkhSaUvnsE8ILvPO/i3voTLzig/6M6KRylE9NqxIpDIx kDrHJQhNGi5wElPpOYnwNWIhAP2tqW3uElKIEGFWti0hHEenqwSnPoOQq4f1Xc5Qr2ue 2MNg== X-Gm-Message-State: ALQs6tCcOaOrgQvl/cMc18COF3qzzWF1UF+KvZo3tK0QWVq00upuW8D1 pt9+L9XZVJlHYNuRzcdKp5QHpw== X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr47753847plk.172.1525908305194; Wed, 09 May 2018 16:25:05 -0700 (PDT) Received: from localhost ([2620:0:1000:1501:8e2d:4727:1211:622]) by smtp.gmail.com with ESMTPSA id q22sm24019772pfk.4.2018.05.09.16.25.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 16:25:04 -0700 (PDT) Date: Wed, 9 May 2018 16:25:03 -0700 From: Matthias Kaehlcke To: Lina Iyer 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, rplsssn@codeaurora.org Subject: Re: [PATCH v8 05/10] drivers: qcom: rpmh-rsc: write sleep/wake requests to TCS Message-ID: <20180509232503.GJ19594@google.com> References: <20180509170159.29682-1-ilina@codeaurora.org> <20180509170159.29682-6-ilina@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180509170159.29682-6-ilina@codeaurora.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lina, On Wed, May 09, 2018 at 11:01:54AM -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 > > --- > > diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c > index c0edf3850147..b5894b001ae1 100644 > --- a/drivers/soc/qcom/rpmh-rsc.c > +++ b/drivers/soc/qcom/rpmh-rsc.c > > > > +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; > + if (i + len >= MAX_TCS_SLOTS) > + goto seq_err; The command cache can have less than MAX_TCS_SLOTS slot: static int rpmh_probe_tcs_config(struct platform_device *pdev, struct rsc_drv *drv) { ... tcs->cmd_cache = devm_kcalloc(&pdev->dev, tcs->num_tcs * ncpt, sizeof(u32), GFP_KERNEL); ... } So the condition needs to be: if (i + len >= tcs->num_tcs * tcs->ncpt) > +static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, > + int *tcs_id, int *cmd_id) > +{ > + int slot, offset; > + int i = 0; > + > + /* Find if we already have the msg in our TCS */ > + slot = find_match(tcs, msg->cmds, msg->num_cmds); > + if (slot >= 0) > + goto copy_data; > + > + /* Do over, until we can fit the full payload in a TCS */ > + do { > + slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS, > + i, msg->num_cmds, 0); > + if (slot == MAX_TCS_SLOTS) > + return -ENOMEM; Like above, use 'tcs->num_tcs * tcs->ncpt' as maximum instead of MAX_TCS_SLOTS. > +static int tcs_ctrl_write(struct rsc_drv *drv, const struct tcs_request *msg) > +{ > + struct tcs_group *tcs; > + int tcs_id = 0, cmd_id = 0; > + unsigned long flags; > + int ret; > + > + tcs = get_tcs_for_msg(drv, msg); > + if (IS_ERR(tcs)) > + return PTR_ERR(tcs); > + > + spin_lock_irqsave(&tcs->lock, flags); > + /* find the m-th TCS and the n-th position in the TCS to write to */ The comment still refers to the old names 'm' and 'n'. Thanks Matthias