Received: by 10.192.165.148 with SMTP id m20csp408573imm; Wed, 9 May 2018 15:04:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo3ED9Js92AoXZO+HVq8RfYyOmzYMHJgYQqFwjjsJKL43FkdqBCTGW2SQ0Sfxlu9KzAwkEA X-Received: by 2002:a63:4383:: with SMTP id q125-v6mr37790828pga.412.1525903452911; Wed, 09 May 2018 15:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525903452; cv=none; d=google.com; s=arc-20160816; b=aCUZHz8dfSKFNAQSWxcek8YLnSV/9vezIiGGGlQFvHjxpNi7lOoTY7QrZlacQO3vam 5i5Y0RRgRvnErF2XQja0AAEEkuRqFlfyiD8yTQvkHOGUHPPAKDhVRn5qdGcwS5n/SfWO Xy3jo9xBLmAAQ/vlTahMXPSPjV2Z8b71jEIHlBwZzfI1w4/00NYWs9uqcettB8fwTcGv DepbP9Zh7WqqKIKOigqvJCUzboJAsN5sBiXwqvg9sgSxCPNvFZe+zeO4HyxjipU6N9Z3 cQjOoYe+bYPUFUIoSg4YXLJh6E9tPBnVUl0XYTPXViy4sa6d1v1uav8L8+1p33kmAkX8 bmCg== 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=ARZYJkvIvbax49X/TipecKLjkZJvsirSnpHdKSXJ+PY=; b=X/xUfQ65tEThaIDurkD9ISkaIj5dCgSmeGwtaygu6mtyljybKY76mLz87EqTXytAmC dWMMFtg45WMWgBmqT5QJHZqiRbmfQioZ4kmO+lTu0VT0i58xj50yLRMCcAY8GgNykQkH x0RD3NEfP9vfC0tX6GLMlEzM55n5bRbBTQgzvqjFz87+QWPq995G8aNrxmNloodkriTP yLzVHwAjHwAyeWd9z21MInH/neVWI9mVkeMWZEFI5N9tJFzWu5hHDPFaGpE6R9ZXkEvU S3PNZj43teZlCGOxeKKhw8pICoGRNwoRLlv3pIY6Q83jo0e/1UMJRhlqJFv0lTjaiTIF zr4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cb9z2lBd; 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 h8si15410872pfh.278.2018.05.09.15.03.58; Wed, 09 May 2018 15:04:12 -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=cb9z2lBd; 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 S965758AbeEIWDJ (ORCPT + 99 others); Wed, 9 May 2018 18:03:09 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:32948 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965450AbeEIWDG (ORCPT ); Wed, 9 May 2018 18:03:06 -0400 Received: by mail-pl0-f68.google.com with SMTP id n10-v6so47270plp.0 for ; Wed, 09 May 2018 15:03:06 -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=ARZYJkvIvbax49X/TipecKLjkZJvsirSnpHdKSXJ+PY=; b=cb9z2lBdlkqRVNQ9snPE8ZypGWQS0j3voEaHe1HebebY3rckT6POPVBkaaHs/FS56x z5SPzAMnpSadNO8CNQJj7nBTs0CQ6KrcGx3NYws90O8cdR8Z7I9EybsWpM/wSUCsfyYE rddD2H+f4WDwN84LhNprH+kMMYzV3qy7UEK0g= 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=ARZYJkvIvbax49X/TipecKLjkZJvsirSnpHdKSXJ+PY=; b=Tc97L+S4nbd2HDANyPPbuf2BmEQhBlCiIaRMKAoU1rySWGaTIa27uVUOKUUCV0zzdh 0HGrkfnfeAiE5zIQuNb4aCmTCWIw3Mq6PMpxof9l7dIkrMXnyuwYfOWI7appteINzCgw gd7JW02dxL5YfDUdXdJ4Tc8jD0huojdaP4/VkShOILryEDa45qFt9p2Pvq6Tigv64f4u hA71t9H7oSkpWU5YToR+N3zSZd5m4yGDPKb/bWBS5nt6N+CakeBgHb/9W2Y0flJ+9qlN XdiDeZS/YHhhz506jrEA3FHBrk0QuWAeXD+cW+vx0hcxiS4v47z+CR4Jrv74mf1vSDz5 JTRA== X-Gm-Message-State: ALQs6tAf0gY7NQ+CuFDozrrFtayuVPZTLTKDAEcH8ehd8tqXPt1QGEAF ePTYcYoHvxxAt2Jn+454Gz7lkA== X-Received: by 2002:a17:902:694b:: with SMTP id k11-v6mr8753868plt.334.1525903386509; Wed, 09 May 2018 15:03:06 -0700 (PDT) Received: from localhost ([2620:0:1000:1501:8e2d:4727:1211:622]) by smtp.gmail.com with ESMTPSA id f21sm50879532pfa.106.2018.05.09.15.03.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 15:03:05 -0700 (PDT) Date: Wed, 9 May 2018 15:03:04 -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 09/10] drivers: qcom: rpmh: add support for batch RPMH request Message-ID: <20180509220304.GI19594@google.com> References: <20180509170159.29682-1-ilina@codeaurora.org> <20180509170159.29682-10-ilina@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180509170159.29682-10-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 On Wed, May 09, 2018 at 11:01:58AM -0600, 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 > --- > > Changes in v7: > - Check for loop out of bounds > > Changes in v6: > - replace rpmh_client with device * > Changes in v4: > - reorganize rpmh_write_batch() > - introduce wait_count here, instead of patch#4 > --- > drivers/soc/qcom/rpmh.c | 154 +++++++++++++++++++++++++++++++++++++++- > include/soc/qcom/rpmh.h | 8 +++ > 2 files changed, 160 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/qcom/rpmh.c b/drivers/soc/qcom/rpmh.c > index 1bb62876795c..a0e277b4b846 100644 > --- a/drivers/soc/qcom/rpmh.c > +++ b/drivers/soc/qcom/rpmh.c > > ... > > +static int flush_batch(struct rpmh_ctrlr *ctrlr) > +{ > + const struct rpmh_request *rpm_msg; > + unsigned long flags; > + int ret = 0; > + int i; > + > + /* Send Sleep/Wake requests to the controller, expect no response */ > + spin_lock_irqsave(&ctrlr->lock, flags); > + for (i = 0; ctrlr->batch_cache[i]; i++) { I missed this earlier: the loop goes beyond ctrlr->batch_cache when the batch cache is full. > + rpm_msg = ctrlr->batch_cache[i]; > + ret = rpmh_rsc_write_ctrl_data(ctrlr->drv, &rpm_msg->msg); > + if (ret) > + break; > + } > + spin_unlock_irqrestore(&ctrlr->lock, flags); > + > + return ret; > +} > + > +static void invalidate_batch(struct rpmh_ctrlr *ctrlr) > +{ > + unsigned long flags; > + int index = 0; > + > + spin_lock_irqsave(&ctrlr->lock, flags); > + while (ctrlr->batch_cache[index]) { This still goes beyond ctrlr->batch_cache when the batch cache is full.