Received: by 10.223.185.116 with SMTP id b49csp24412wrg; Thu, 22 Feb 2018 15:47:02 -0800 (PST) X-Google-Smtp-Source: AH8x227/I5SH7GhkGtIyEns59Hsl4vi9PXq+fGVTyveO6JU++1mkyp0nay2i6a1EWOwYDhP5okQ/ X-Received: by 10.98.69.146 with SMTP id n18mr8528695pfi.29.1519343222096; Thu, 22 Feb 2018 15:47:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519343222; cv=none; d=google.com; s=arc-20160816; b=nyhYtGEg+NrHZWi91jngoizHdzVIBo13UqYI31qqiMNfT7VaAeiqbt3ta/bFZf9iPR pz8Tv2z0F3x1Z0zZXpdiHhyE+qsRIWTlRXMf8fsRbzmCbVDjbadPhpKMUGch8KexM0Sa vHnIw/tuN9VCl9+MKGw3+7uG8ml3FOLRY+XyrrsVU3vQGYkhdGP0FFRamo50J0b2bIpu ViJvBIFCfCQn4GjcD9UMMuFF9UYzMIpUYthQi/t3qqmeH5cPi4RhrRYKgKEZIZek780I JAlI0+4UYO/WceD6z2DMpjkGHY1pU172JYshmb00jwYIhI2w7ZCbdGaSgHsfJLkfWCt6 kS/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=HqhqIUaXU0cELs64nPq3H2oNSR1vQgeZLWeDrLnhF28=; b=R379WV7xrT8wZ3zCGAzItatbYDHVFaUKyct33XF15iTQrIEkT1brheI3mB3VBn7jVP jbts4MksgrycVgSWUSheI/MGoBZDy6tLJna+pM0Rt+ZTIFxoY0QQyG4aKLrGeQPUnVtR f797cTYa1ddLJDkpoqhDdowgO6kgIXjILyamlD2Gq1isJNPcqqzGpKxG8KGsVWr3oKEX lM180EUmRGYmnDDKRDzz00Fuua73O34x42Z6qPP/PwVc9H6D/VrigIeKHGr7G0inv0sf QnivVlMhp+zKqkYV3u3xnSMA3tME5k9LTSDUUP8DP7Uc5Gv94pfQj8rF/nbES5Wh49iO zP3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GA1pYhcD; 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 t11-v6si788923plr.411.2018.02.22.15.46.47; Thu, 22 Feb 2018 15:47:02 -0800 (PST) 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=GA1pYhcD; 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 S1751916AbeBVXqC (ORCPT + 99 others); Thu, 22 Feb 2018 18:46:02 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:42246 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751436AbeBVXp7 (ORCPT ); Thu, 22 Feb 2018 18:45:59 -0500 Received: by mail-ot0-f195.google.com with SMTP id a7so6257085otk.9 for ; Thu, 22 Feb 2018 15:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HqhqIUaXU0cELs64nPq3H2oNSR1vQgeZLWeDrLnhF28=; b=GA1pYhcDZFYpGOK5LckNoWlFo2ZnDjh3yZ84Z4cFzsHPMC1t339vMdIJiOtded2Dtx Dm2oxx4m9CqjZ5qJPvJ6kVrAsZ6fI6dfDa/O7e/DAVfaXYks9jjB1VlNVS0WH7Lx2Z5U sCbQw7QGwNwF54+H7IpaPNNegTJVpOc0pVw1w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HqhqIUaXU0cELs64nPq3H2oNSR1vQgeZLWeDrLnhF28=; b=eWFmubYetuxlMpHx6oEiO1KabZELrLX3BUrMrFepRDLl5jNRqL/RCYUYWEplUDxtVI VT988fb3SBD404IMorGXgTmu0pTdY/35SjtqEsp05l3T3gjj4TuG/Nf4xiFWxZJqrYCF q+mfMf6XQdfU0SNj0FCU4aHG6MY68BEKxoKiCNyxrOWxv7F/2rU40mfXjRwm5vY2gWPi YFxioOaUkXb2abcAVS4KFmaqFc++I6/rUIItR92WJhj23DP0MFY+VeMrjTw3rLjwEJ/3 1ek/X3CGCNAodeTGiCQ66iOHqcopwKtSzM9iLW1s7KZkVEJfPvZ9Zs8PDGr4UcAKgl1S H4bQ== X-Gm-Message-State: APf1xPCPmm1Fpgu4hVPUADPILAEnQcpJaAVNLpk2WPx2u+nTLvsuD5Ek SIeTp0DMBUPapM+Uj8z4fM4QyiATScA= X-Received: by 10.157.46.112 with SMTP id c45mr5929329otd.124.1519343159016; Thu, 22 Feb 2018 15:45:59 -0800 (PST) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com. [209.85.218.44]) by smtp.gmail.com with ESMTPSA id 36sm654965otb.33.2018.02.22.15.45.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Feb 2018 15:45:57 -0800 (PST) Received: by mail-oi0-f44.google.com with SMTP id e10so5039898oiy.8 for ; Thu, 22 Feb 2018 15:45:57 -0800 (PST) X-Received: by 10.202.5.66 with SMTP id 63mr5423018oif.266.1519343156937; Thu, 22 Feb 2018 15:45:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.14.33 with HTTP; Thu, 22 Feb 2018 15:45:16 -0800 (PST) In-Reply-To: <20180222170451.GB7098@codeaurora.org> References: <20180215173507.10989-1-ilina@codeaurora.org> <20180215173507.10989-10-ilina@codeaurora.org> <20180222170451.GB7098@codeaurora.org> From: Evan Green Date: Thu, 22 Feb 2018 15:45:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 09/10] drivers: qcom: rpmh: add support for batch RPMH request To: Lina Iyer Cc: Andy Gross , David Brown , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, Rajendra Nayak , Bjorn Andersson , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lina, On Thu, Feb 22, 2018 at 9:04 AM, Lina Iyer wrote: > On Wed, Feb 21 2018 at 23:25 +0000, Evan Green wrote: >> >> Hello Lina, >> >> On Thu, Feb 15, 2018 at 9:35 AM, Lina Iyer wrote: >>> >>> Platform drivers need make a lot of resource state requests at the same >>> time, say, at the start or end of an usecase. It can be quite >>> inefficient to send each request separately. Instead they can give the >>> RPMH library a batch of requests to be sent and wait on the whole >>> transaction to be complete. >>> >>> rpmh_write_batch() is a blocking call that can be used to send multiple >>> RPMH command sets. Each RPMH command set is set asynchronously and the >>> API blocks until all the command sets are complete and receive their >>> tx_done callbacks. >>> >>> Signed-off-by: Lina Iyer >>> --- >>> drivers/soc/qcom/rpmh.c | 150 >>> ++++++++++++++++++++++++++++++++++++++++++++++++ >>> include/soc/qcom/rpmh.h | 8 +++ >>> 2 files changed, 158 insertions(+) >>> >>> diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c >>> index dff4c46be3af..6f60bb9a4dfa 100644 >>> --- a/drivers/soc/qcom/rpmh.c >>> +++ b/drivers/soc/qcom/rpmh.c >> >> [...] >>> >>> @@ -394,6 +537,11 @@ int rpmh_flush(struct rpmh_client *rc) >>> } >>> spin_unlock_irqrestore(&rpm->lock, flags); >>> >>> + /* First flush the cached batch requests */ >>> + ret = flush_batch(rc); >>> + if (ret) >>> + return ret; >>> + >>> /* >>> * Nobody else should be calling this function other than system >>> PM,, >>> * hence we can run without locks. > > This comment and the comment in the header of this function. > >>> @@ -438,6 +586,8 @@ int rpmh_invalidate(struct rpmh_client *rc) >>> if (IS_ERR_OR_NULL(rc)) >>> return -EINVAL; >>> >>> + invalidate_batch(rc); >>> + >> >> >> Similarly to my comments in patch 7, aren't there races here with >> adding new elements? After flush_batch, but before invalidate_batch, >> somebody could call cache_batch, which would add new things on the end >> of the array. These new items would be clobbered by invalidate_batch, >> without having been flushed first. >> > Flush is a system PM function and is not called by drivers and is not > expected to run conncurrently with other threads using the RPMH library. My comment above was a little off because I was reading those two hunks (flush_batch and invalidate_batch) as being in the same function. They're not. I'm okay with the locking here, though you could remove the locking from flush_batch, since that's only run in single-threaded PM contexts. > > Thanks, > Lina >