Received: by 10.192.165.148 with SMTP id m20csp910584imm; Fri, 27 Apr 2018 09:25:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpVmwnH9GDLYmKuHVenjLjdD/2FD6sgssuUsUywnm9ppZJNUcEW+AR3e5IDNI3z52i7/He3 X-Received: by 2002:a17:902:6181:: with SMTP id u1-v6mr2857145plj.272.1524846347349; Fri, 27 Apr 2018 09:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524846347; cv=none; d=google.com; s=arc-20160816; b=NbW5gGPveBPAHRATPONLQxxSxmNchZwkCSEGU/h1r3c4zKR74yq0gwivlTMJzWkDAS 8ynb4a4STfBIwrIKEqAhWTOgBxNhltp2lfCTWQAGCj0WnZ7CFN2LTtYbMnckCp1c7BK2 vn2Kn47juPonj69if9UnakEV7P8jK01y1iK2NBFE4AYSO0CThPmLyiFq/Js5Zr8lp+Ku T1DiNrRiohiXY6wcsZfPrC+gQTh7Y0tJxHVbWwOV68pr1YLEts3OhFemuBzhL8xCt5XP t+2j25hxMG881pnMXZtGtlZikJdtNTFs01+xNFfawp2+Nl8pCD1Fd/fQErfdEoKOQu9f 8eyQ== 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=+cz6MwymIfv2rM6viGkxCrIp3AmHvArCihSXR1o/VeU=; b=QIAMxhmIuLqNoiBbTA8lrKS+bSI7jrDBVnlj1l++U+sroL2jepwT2DPtBdNuywEN6U V3s6h3ja/ojziMjW/joejA45gFAntzo0qcGXLZGyo4zBbwIEn5nEEXNc6FvymJw7QcbG 9wBbbXs23uamrtRkdUlM2LCUuR3SI7lIH/O5s2ADShF9wgcGNFMy3MsCMUOPoiEGoGWY RP3rziErEusKA9rJRaeeAXGmRVXSpB0Im6OlhJ19IpdbqZazSoh5hBn7oVzRAfzYETK+ +DSt34ANYHjF1kQR+TvAPu9YzAFk1siajMG172vPeVBRXKXVXHBVFZ4xClfMQlFhYkGB koTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=hoyqNZ4I; dkim=pass header.i=@codeaurora.org header.s=default header.b=h7ZMO5Um; 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 w19-v6si1511675plp.538.2018.04.27.09.25.33; Fri, 27 Apr 2018 09:25:47 -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=hoyqNZ4I; dkim=pass header.i=@codeaurora.org header.s=default header.b=h7ZMO5Um; 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 S1758728AbeD0QYS (ORCPT + 99 others); Fri, 27 Apr 2018 12:24:18 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49702 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758563AbeD0QYK (ORCPT ); Fri, 27 Apr 2018 12:24:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4CC4860452; Fri, 27 Apr 2018 16:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524846250; bh=vgIqSef3GYxPGjqpP79V/AlorAmP2WJJxKEWufHJIQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hoyqNZ4I+89Pl+jC7d4rfV21PrpiYiWkOctEyYkmo9a+0BlwEhHuLRpGj6pU3QlJQ gEeDVRuHNKgedb3wJfF/lWAXyTyN68aU1SMVe1gfbcw1sDHp3N+/aMHYXUICHVg+F1 fq9fW9tmQa18wWxY0re7q1Tr0/qaDebPWRKb/YLo= 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 4569B60452; Fri, 27 Apr 2018 16:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524846249; bh=vgIqSef3GYxPGjqpP79V/AlorAmP2WJJxKEWufHJIQw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=h7ZMO5Um9lVPEfjI4wmtj5THXRPPYFmf87qHGzpzEJdycTJeY9Z7OonR4VI5w+rgU imzZhC/XKUnfSjHFWxKFqkloP1AM68y6gXXKHfJJGtqDIk8LbNqK9wk43KzKKgY06l HWaAep9T83F5xrdiypat/PwX5taHbvzAV6x3/jZo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4569B60452 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: Fri, 27 Apr 2018 10:24:08 -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 Subject: Re: [PATCH v6 09/10] drivers: qcom: rpmh: add support for batch RPMH request Message-ID: <20180427162408.GA6380@codeaurora.org> References: <20180419221635.17849-1-ilina@codeaurora.org> <20180419221635.17849-10-ilina@codeaurora.org> <20180425234149.GE243180@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180425234149.GE243180@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, Apr 25 2018 at 17:41 -0600, Matthias Kaehlcke wrote: >On Thu, Apr 19, 2018 at 04:16:34PM -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 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 | 155 +++++++++++++++++++++++++++++++++++++++- >> include/soc/qcom/rpmh.h | 8 +++ >> 2 files changed, 161 insertions(+), 2 deletions(-) >> > > >> +static int cache_batch(struct rpmh_ctrlr *ctrlr, >> + struct rpmh_request **rpm_msg, int count) >> +{ >> + unsigned long flags; >> + int ret = 0; >> + int index = 0; >> + int i; >> + >> + spin_lock_irqsave(&ctrlr->lock, flags); >> + while (ctrlr->batch_cache[index]) >> + index++; > >This will access memory beyond 'batch_cache' when the cache is full. > Ok. Will check for index. > > >> +static void invalidate_batch(struct rpmh_ctrlr *ctrlr) >> +{ >> + unsigned long flags; >> + int index = 0; >> + int i; >> + >> + spin_lock_irqsave(&ctrlr->lock, flags); >> + while (ctrlr->batch_cache[index]) >> + index++; > >Same as above. Also, why loop twice? > Good idea. Will fix. >> + for (i = 0; i < index; i++) { >> + kfree(ctrlr->batch_cache[i]->free); >> + ctrlr->batch_cache[i] = NULL; >> + } > > > >> +/** >> + * rpmh_write_batch: Write multiple sets of RPMH commands and wait for the >> + * batch to finish. >> + * >> + * @dev: the device making the request >> + * @state: Active/sleep set >> + * @cmd: The payload data >> + * @n: The array of count of elements in each batch, 0 terminated. > >nit: in this driver 'n' is usually associated with the command offset >within a TCS. Since it isn't an overly descriptive name it may already >cost the reader a while to commit that to his/her memory, and now >we are overloading 'n' with a different meaning (I also noticed this in >another patch of this series, but didn't comment). > Sure, will change the variable name here. >> /* >> * Nobody else should be calling this function other than system PM,, > ~ >Remove extra comma. OK. Thanks, Lina