Received: by 10.192.165.148 with SMTP id m20csp1280979imm; Thu, 10 May 2018 08:18:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqgnalXc5MgmsRYuavsgheBy1UnQyui92N+ERn8mO4L8vsHBUTpWS2Agmo9kOFb8ocT9HgJ X-Received: by 2002:a17:902:aa03:: with SMTP id be3-v6mr1786683plb.61.1525965486739; Thu, 10 May 2018 08:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525965486; cv=none; d=google.com; s=arc-20160816; b=d1RzrawsXiqiCCUCB74jx1qJMaNUiUc6+K/FjG/dXhK0r47xydd5P8dPkD1TN3ZlDs BHjKWoULNI2clSiVXKRG17RLJQoCZT8KEBRnXyJ4Uj9G4SU7djwXQ/5xz1CYiFli3iNZ /t8aHkTtzddBRY4/sArOjazmYQIcG8Jv3SCOFI4jU6po4LqDZ3Q9AdkwwC6NkHA+23Rz 1d1TWigXEEkIzDI/BZxHGpYXhNXFmT87/GlcRX9+eiYX66Ioqj4IWqZ//WcM8IR59gM+ r+ojw1edSWg5O3HbPBl8XaeMKU/pU0kvabJ6PjnhEJjEbIklcCUxYWyFxloWAgYX4CDk DTpA== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=jUDJH9egomzUkjkb3H22iWHM8vu9cNRt1mYo6RyChDQ=; b=WrlulpI8rvslo4RoL70LA41doNDYlwLjncyAPVNlvddbUgbZmWKq9HpLoZxKNt1Uzb cE6FedwIxvT5XWxwYFTYnBDEt9kEFwomsKFJQ7x35ay5VdOeyhxoYvwhWWqse1cIksZz 6kbdlWgJY15eYFEN7KsbDACeTlw19foBY5nQptmx7Omg2F1nNW+uYGiRUYYt3pJBQ1mK zKL4nbqLBK2fs3RmiUC/J4u5nBL5fDtQ9S8C1okt5Py5Qdax7YRq8TU83YEf+mF2v4w2 emxHEhTCkUxar/tvLp13U0e8VP5H3FAyBt4vz9gtY1hblPtRGmzDwU66z6iW9KLin88C frVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GeDuhVAO; dkim=pass header.i=@codeaurora.org header.s=default header.b=Dj/kzyom; 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 y185-v6si830863pgd.316.2018.05.10.08.17.52; Thu, 10 May 2018 08:18:06 -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=GeDuhVAO; dkim=pass header.i=@codeaurora.org header.s=default header.b=Dj/kzyom; 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 S966191AbeEJPRT (ORCPT + 99 others); Thu, 10 May 2018 11:17:19 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43194 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964827AbeEJPRR (ORCPT ); Thu, 10 May 2018 11:17:17 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7A1F9609D1; Thu, 10 May 2018 15:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525965436; bh=Np/mifjWwAF6XL9O6EIvd+w8To/5nVVQkGSAyEFzD+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GeDuhVAOg5O0fyJaLKiNyXYZryJZXhhSVPb0MveIimZk3ysvsudI6YFA8Dml42MAD ametelBaRr8Hpm9Lcx7IFUzlGjdwBUbfXwvi6+cSAIMQjEWSt6O1A80J/YUvGDU+5m 7qUD950wJwUe1tZKL87tTpzTAZxWiEMxkaNAYAO0= 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 localhost (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: ilina@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 779AB6019F; Thu, 10 May 2018 15:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525965435; bh=Np/mifjWwAF6XL9O6EIvd+w8To/5nVVQkGSAyEFzD+I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dj/kzyomKxF3LGupKEorXfcaKLyzAWtyPIUx/amKriPqKuNWEE1a/fKVLblKT8MeO Gcli7/bQOGmMgx4BQsWB5rzedphmK8Mf5UM9ZxQO743YQ8XkArKUXOu2BCB0cqvH2x dkkyIgn2YRqQw1YCy6IHoi5sUP0Zc+bxUlI4jRaE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 779AB6019F 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 Date: Thu, 10 May 2018 09:17:14 -0600 From: Lina Iyer 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, rplsssn@codeaurora.org Subject: Re: [PATCH v8 09/10] drivers: qcom: rpmh: add support for batch RPMH request Message-ID: <20180510151714.GI4698@codeaurora.org> References: <20180509170159.29682-1-ilina@codeaurora.org> <20180509170159.29682-10-ilina@codeaurora.org> <20180509220304.GI19594@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180509220304.GI19594@google.com> User-Agent: Mutt/1.9.5 (2018-04-13) 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 16:03 -0600, Matthias Kaehlcke wrote: >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. I will check through the code for all out-of-bounds. Seems like I have not worried about it too much. Well the space here assigned is beyond what we see on a production device. Neverthless, it needs to be checked. Thanks for your review Matthias. -- Lina