Received: by 10.213.65.68 with SMTP id h4csp513712imn; Fri, 16 Mar 2018 10:03:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELvWTnjR9RfDZVf/0AhpnjE+J77sMILUBkHQ1q9VbQMShzkHMpMKDcdr1wlsr6P80ZFAikdg X-Received: by 10.99.122.80 with SMTP id j16mr2015948pgn.5.1521219805742; Fri, 16 Mar 2018 10:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521219805; cv=none; d=google.com; s=arc-20160816; b=ORF/5CEQH0lcvKCPN+mF8sGNFZR28YKKSYHEpwxMOFbPjXSv3K7HSUrkhcuSI+uqph MYegRDZS0En2k90YlZzwkYjHtqiizlvt07Z6SxjyNDIGpuF9jPWS5T4v7pGDAoBTu3K5 8jxgLD7XxgvQZuH5RjOfvj8kqkyzh6rhpYwSAKzAHAyh8i8j6xKQJ2XVbdL31DQZSFcC AqCxMCoWBYzUQdNz1KR1nFG/fK72GPpIzi0WmzU3JsVBsjJ93NzCiord+YUda9pELn0K xXRIbb7YkJJkuhSVwfCWI2wc1dEQsMxnBAfj/JWjbQFinCfPOMadPWjKZKJ+uuxXn6QE y8gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=Mztvdxrn2VIDbNRykocq1rXNuicPaRYCeuaQlM8F9a0=; b=mdeNbuNd2CU8xHGLMt3T0Lu4s6dxma3yqNNfqfpKfTewmPN+opK+Ab/cjpNPbsPY/c F8p8ZAV+PGADO2YQr0Gl1zErAnmvNJ6PeYV68K2bKqHlti1uO1QHp/2hWWqVIPfNt3AE 2a/hMbNPShctDytcpu66OyzfbQCmI4KSueYKm5fJx4LXw1iqGdxhBRSJv5kcXVBHPzAp pv5Ls77WdYpG2sR60pq7Z9VMssfevRuur5LR/S9ookluRUVqFTUcbbn2FMAYx90ighP5 F5Vg6JhlAhOJ4WYu0ZJSlmOS5FlaegGuaS+n7BdfL9wf5uOHLneOIg0WDdG8d6xDZoKr JtEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N1OOyJCN; 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 m10si5205883pgs.236.2018.03.16.10.03.09; Fri, 16 Mar 2018 10:03:25 -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=N1OOyJCN; 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 S1753685AbeCPRAt (ORCPT + 99 others); Fri, 16 Mar 2018 13:00:49 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33889 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbeCPRAq (ORCPT ); Fri, 16 Mar 2018 13:00:46 -0400 Received: by mail-pf0-f176.google.com with SMTP id j20so4383778pfi.1 for ; Fri, 16 Mar 2018 10:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date; bh=Mztvdxrn2VIDbNRykocq1rXNuicPaRYCeuaQlM8F9a0=; b=N1OOyJCNO6+0W0mTI7FLI76Z6TDtNNbt2kDRNhYKASIeWVgvpmM8q+V+hDM5G9vE87 Usnv+xYX0oN0hgKJLFxaAWOJWbGLFRk992fnwJ7lbmQKFvIV1YoJYlAMJ5tvxo846R/x OEef+LyN0QT+baUkjY0d9cMpKVHnuAbNQbewg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=Mztvdxrn2VIDbNRykocq1rXNuicPaRYCeuaQlM8F9a0=; b=bSXR70MOnWqEFmcijmexhOO1fHb5QJ5QiRJNrtObg1U4Hs1f1AXmTickE+OgrLAEI/ w9WHBewmk1vyaprFQ1B01DO0ScSrGkTLNo3VeIKkmr3VRT4dcL2W7F+KWRe7jzIyahaO GWDxBpid/IGWYye3oXuHzoYPUhvyBwMTaGDtS0rSt1b28FRY/DZ0IUAvp6rYHDe1aVAP skQJbpsgpvAZtkQNblBs4QttgnYPL8bt8xDX8s61WlG61Bf9V7xDZM0li8ZPhgEHn972 duyjCFVTwU9GZUEhYqawODh+JpnTgwwIanC1OYr3MnR3x5ieQxzagJ0cXVoV4sRQ1ZwW E/dQ== X-Gm-Message-State: AElRT7GLuHvsdpQW4jKPwFXYfxR+OQFGWdQ5MRQAo/KuTABdLrIaENVQ B9nIF1+/ac46sjX4KR2wy0/X4Q== X-Received: by 10.99.104.73 with SMTP id d70mr1983909pgc.107.1521219645543; Fri, 16 Mar 2018 10:00:45 -0700 (PDT) Received: from localhost ([2620:0:1000:1511:d30e:62c6:f82c:ff40]) by smtp.gmail.com with ESMTPSA id u71sm16937703pfd.152.2018.03.16.10.00.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Mar 2018 10:00:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Lina Iyer From: Stephen Boyd In-Reply-To: <20180308225540.GB3577@codeaurora.org> 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 References: <20180302164317.10554-1-ilina@codeaurora.org> <20180302164317.10554-10-ilina@codeaurora.org> <152054637377.219802.5175262314364284431@swboyd.mtv.corp.google.com> <20180308225540.GB3577@codeaurora.org> Message-ID: <152121964417.179821.6748540781312701645@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v3 09/10] drivers: qcom: rpmh: add support for batch RPMH request Date: Fri, 16 Mar 2018 10:00:44 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2018-03-08 14:55:40) > On Thu, Mar 08 2018 at 14:59 -0700, Stephen Boyd wrote: > >Quoting Lina Iyer (2018-03-02 08:43:16) > >> @@ -343,6 +346,146 @@ int rpmh_write(struct rpmh_client *rc, enum rpmh= _state state, > >> } > >> EXPORT_SYMBOL(rpmh_write); > >> > >> +static int cache_batch(struct rpmh_client *rc, > >> + struct rpmh_request **rpm_msg, int count) > >> +{ > >> + struct rpmh_ctrlr *rpm =3D rc->ctrlr; > >> + unsigned long flags; > >> + int ret =3D 0; > >> + int index =3D 0; > >> + int i; > >> + > >> + spin_lock_irqsave(&rpm->lock, flags); > >> + while (rpm->batch_cache[index]) > > > >If batch_cache is full. > >And if adjacent memory has bits set.... > > > >This loop can go forever? > > > >Please add bounds. > > > How so? The if() below will ensure that it will not exceed bounds. Right, the if below will make sure we don't run off the end, but unless rpm->batch_cache has a sentinel at the end we can't guarantee we won't run off the end of the array and into some other portion of memory that also has a bit set in a word. And then we may read into some unallocated space. Or maybe I missed something. > = > >> + index++; > >> + if (index + count >=3D 2 * RPMH_MAX_REQ_IN_BATCH) { > >> + ret =3D -ENOMEM; > >> + goto fail; > >> + } > >> + > >> + for (i =3D 0; i < count; i++) > >> + rpm->batch_cache[index + i] =3D rpm_msg[i]; > >> +fail: > >> + spin_unlock_irqrestore(&rpm->lock, flags); > >> + > >> + return ret; > >> +} > >> + > = > >> + * @state: Active/sleep set > >> + * @cmd: The payload data > >> + * @n: The array of count of elements in each batch, 0 terminated. > >> + * > >> + * Write a request to the mailbox controller without caching. If the = request > >> + * state is ACTIVE, then the requests are treated as completion reque= st > >> + * and sent to the controller immediately. The function waits until a= ll the > >> + * commands are complete. If the request was to SLEEP or WAKE_ONLY, t= hen the > >> + * request is sent as fire-n-forget and no ack is expected. > >> + * > >> + * May sleep. Do not call from atomic contexts for ACTIVE_ONLY reques= ts. > >> + */ > >> +int rpmh_write_batch(struct rpmh_client *rc, enum rpmh_state state, > >> + struct tcs_cmd *cmd, int *n) > > > >I'm lost why n is a pointer, and cmd is not a double pointer if n stays > >as a pointer. Are there clients calling this API with a contiguous chunk > >of commands but then they want to break that chunk up into many > >requests? > > > That is correct. Clients want to provide a big buffer that this API will > break it up into requests specified in *n. Is that for bus scaling? > >> + return PTR_ERR(rpm_msg[i]); > >> + } > >> + cmd +=3D n[i]; > >> + } > >> + > >> + /* Send if Active and wait for the whole set to complete */ > >> + if (state =3D=3D RPMH_ACTIVE_ONLY_STATE) { > >> + might_sleep(); > >> + atomic_set(&wait_count, count); > > > >Aha, here's the wait counter. > > > :) > I am removing it from the earlier patch and introducing the wait_count > here. Not bad as I though. Thanks! > = > >> + for (i =3D 0; i < count; i++) { > >> + rpm_msg[i]->completion =3D &compl; > >> + rpm_msg[i]->wait_count =3D &wait_count; > > > >But then we just assign the same count and completion to each rpm_msg? > >Why? Can't we just put the completion on the final one and have the > >completion called there? > > > The order of the responses is not gauranteed to be sequential and in the > order it was sent. So we have to do this. OK! That is sad. > = > >> + /* Bypass caching and write to mailbox directl= y */ > >> + ret =3D rpmh_rsc_send_data(rc->ctrlr->drv, > >> + &rpm_msg[i]->msg); > >> + if (ret < 0) { > >> + pr_err( > >> + "Error(%d) sending RPMH message addr= =3D0x%x\n", > >> + ret, rpm_msg[i]->msg.payload[0].addr); > >> + break; > >> + } > >> + } > >> + /* For those unsent requests, spoof tx_done */ > > > >Why? Comments shouldn't say what the code is doing, but explain why > >things don't make sense. > > > Will remove.. > = Oh, I was hoping for more details, not less.