Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp392373ybl; Tue, 20 Aug 2019 22:30:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaOpvtpd12MqfvGpC0wYrGmnmjIMqyznWM8LN/48oHrg3dbo4f1DSU5uuxHrkWITxVHn4g X-Received: by 2002:a17:90a:bf91:: with SMTP id d17mr3385413pjs.111.1566365454672; Tue, 20 Aug 2019 22:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566365454; cv=none; d=google.com; s=arc-20160816; b=XqAMtu/ATwRNDAqAu2+iKKXjvjYaPXYX91AIa3p3Lz0CUw7GF2jvUNnnYD9FPz/1Mk j1KCLdR2dYyqr6/wYIvPMEHqv5erFu+ZYCVjnKa/u3w1kKNPoDdXdT3pL/Cih9LowuJb L/9XejMjGR+SB497nA1rbeegiFHIMjIid4yTcRnZC9u4ieephX74HjTR3+YwG+9bZ345 /vhXVxiUc698tqTK7YORCEd18imaV4C8Ph0RUg9JjbX6o36vI9WevxSKAazrFdCPFIiL cZFxB1OSSJvsehT+k4/HWRxGZaygmq5TD90dpZMcv9E70Crxxpl1bxA6X7kkuO3+n/Qe 2xkQ== 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; bh=gk5hBFL+zVsGTiYjgXO/Fpozdyng3BO4uoV137GL+GU=; b=Mv0+4aUQX3H0BEGdHfb8LZclPzy47drUwL+80ZPveWLHYk3QkfoXA+9lwHS1Qa0yrl AkUenEXY1SUFs1KbPpOaajsXIcX0v+Iyn/DsAIH2NnWzg4zulFJ9xxIMSulmj/IaVYuN TMVbOouGuygspZ2qbGYRsGGrRiFY94jd86d//8MXqT6b7snEFGnNamn8iC9N1mCqjS+I V8ryqgBgRERlp4t294RWrLQa6px3jYUszGi+29Y4CXWp5ZVxl78deXomJCJy8J//w7lw pT1kkqlv7bLQH9Y2LnMDjpO9hlst/CYyEEGouzpjiGJOxtGpEmYjZtC0EY0etZyfvcz7 DlFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e1jxa3Q2; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h63si1530268pje.79.2019.08.20.22.30.39; Tue, 20 Aug 2019 22:30:54 -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=@linaro.org header.s=google header.b=e1jxa3Q2; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbfHUFXe (ORCPT + 99 others); Wed, 21 Aug 2019 01:23:34 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33208 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727470AbfHUFXe (ORCPT ); Wed, 21 Aug 2019 01:23:34 -0400 Received: by mail-pf1-f196.google.com with SMTP id g2so650710pfq.0 for ; Tue, 20 Aug 2019 22:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=gk5hBFL+zVsGTiYjgXO/Fpozdyng3BO4uoV137GL+GU=; b=e1jxa3Q2588Ob9x6kW+s98HVpKflZuV51sDkqtp1W7M8fFuoqNQieOx7XZgYvhjCk0 ptDwUw++oSPtE+AvV6FIcHMe/DX7cQFvbBIMEEAzzuWl9ycVL+cHnh13QfH7c2ZUUDzR 9/gA3TfjozoAmsjCnQ4yO9ysbAYro+Q0yOlsCS7kfY/L2L6We8rjnip9UtW7ADIAJNMi +aT12kxKsenm1fwscCl+gPp5DeI5envtkvKy7dkQbJz3taB7zyIBNdM/ZbO1DWU9630R 5SbnJh1dVsilH3YyeEMFNknte5bbP2l/TtEVu86taqh1PatWR97T7F0peZwnIVmypl1h /z+g== 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=gk5hBFL+zVsGTiYjgXO/Fpozdyng3BO4uoV137GL+GU=; b=LvTjqSj/5KA0AlzJiyfHABsrPp80x1von8MnqaAyfdlECL87kQmsOp/cyViEQTfmIo T1H/5djYsKvyIL1EOtSnuvN0weL9Mrtc0ZCU9DW4joz/1Qhh+vHasjuMsmqG4LIBHqMr S+9CQgAqjOQzRZR9Ue9iIjlJg8QU8z5wASR4akZOiA2bkepuWreK+Ob0JnVnOdio1WHa cpjMy1NRe5EgtwVe4R6+GyV4FoNx8wfqRXIhDtgm6PINPLhb1eiQrDk+gMD0nR6ybEiU Zu3ZIQAmR8g6gwuzkdts5gmoA75iHOrPMG8liO9j2ssj7aGbmtJVrgX5xMbGWd+ISYlT GeIg== X-Gm-Message-State: APjAAAVBeUCA6hT2rHBmqxWvc9g+iBdbLjeVtxT9ydinu21eZZ+GKJXq bKC8CjMT2R3i/XxtQ+Icz18vGQ== X-Received: by 2002:a62:c584:: with SMTP id j126mr33906007pfg.21.1566365013017; Tue, 20 Aug 2019 22:23:33 -0700 (PDT) Received: from localhost ([122.172.76.219]) by smtp.gmail.com with ESMTPSA id l4sm1781386pjq.9.2019.08.20.22.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Aug 2019 22:23:32 -0700 (PDT) Date: Wed, 21 Aug 2019 10:53:30 +0530 From: Viresh Kumar To: Saravana Kannan Cc: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Georgi Djakov , Vincent Guittot , "Sweeney, Sean" , David Dai , adharmap@codeaurora.org, Rajendra Nayak , Sibi Sankar , Bjorn Andersson , Evan Green , Android Kernel Team , Linux PM , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML Subject: Re: [PATCH v5 2/3] OPP: Add support for bandwidth OPP tables Message-ID: <20190821052330.7zufh7hhurq7ictp@vireshk-i7> References: <20190807223111.230846-1-saravanak@google.com> <20190807223111.230846-3-saravanak@google.com> <20190820061300.wa2dirylb7fztsem@vireshk-i7> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-391-311a52 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20-08-19, 15:27, Saravana Kannan wrote: > On Mon, Aug 19, 2019 at 11:13 PM Viresh Kumar wrote: > > > > On 07-08-19, 15:31, Saravana Kannan wrote: > > > Not all devices quantify their performance points in terms of frequency. > > > Devices like interconnects quantify their performance points in terms of > > > bandwidth. We need a way to represent these bandwidth levels in OPP. So, > > > add support for parsing bandwidth OPPs from DT. > > > > > > Signed-off-by: Saravana Kannan > > > --- > > > drivers/opp/of.c | 41 ++++++++++++++++++++++++++++++++--------- > > > drivers/opp/opp.h | 4 +++- > > > 2 files changed, 35 insertions(+), 10 deletions(-) > > > > > > diff --git a/drivers/opp/of.c b/drivers/opp/of.c > > > index 1813f5ad5fa2..e1750033fef9 100644 > > > --- a/drivers/opp/of.c > > > +++ b/drivers/opp/of.c > > > @@ -523,6 +523,35 @@ void dev_pm_opp_of_remove_table(struct device *dev) > > > } > > > EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); > > > > > > +static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np) > > > +{ > > > + int ret; > > > + u64 rate; > > > + u32 bw; > > > + > > > + ret = of_property_read_u64(np, "opp-hz", &rate); > > > + if (!ret) { > > > + /* > > > + * Rate is defined as an unsigned long in clk API, and so > > > + * casting explicitly to its type. Must be fixed once rate is 64 > > > + * bit guaranteed in clk API. > > > + */ > > > + new_opp->rate = (unsigned long)rate; > > > + return 0; > > > + } > > > + > > > > Please read opp-level also here and do error handling. > > Can you please explain what's the reasoning? opp-level doesn't seem to > be a "key" based on looking at the code. Because opp-level is the thing that distinguishes OPPs for power domains, those nodes don't have opp-hz or bw. > > > + ret = of_property_read_u32(np, "opp-peak-kBps", &bw); > > > + if (ret) > > > + return ret; > > > + new_opp->rate = (unsigned long) bw; > > > + > > > + ret = of_property_read_u32(np, "opp-avg-kBps", &bw); > > > + if (!ret) > > > + new_opp->avg_bw = (unsigned long) bw; > > > > If none of opp-hz/level/peak-kBps are available, print error message here > > itself.. > > But you don't print any error for opp-level today. Seems like it's optional? Yeah, probably it should have been there. It will be better to do it now as we are creating a separate routine for that. > > > > > + > > > + return 0; > > > > You are returning 0 on failure as well here. > > Thanks. > > > > +} > > > + > > > /** > > > * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) > > > * @opp_table: OPP table > > > @@ -560,22 +589,16 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, > > > if (!new_opp) > > > return ERR_PTR(-ENOMEM); > > > > > > - ret = of_property_read_u64(np, "opp-hz", &rate); > > > + ret = _read_opp_key(new_opp, np); > > > if (ret < 0) { > > > /* "opp-hz" is optional for devices like power domains. */ > > > if (!opp_table->is_genpd) { > > > - dev_err(dev, "%s: opp-hz not found\n", __func__); > > > + dev_err(dev, "%s: opp-hz or opp-peak-kBps not found\n", > > > + __func__); > > > goto free_opp; > > > } > > > > > > rate_not_available = true; > > > > Move all above as well to read_opp_key(). > > Ok. I didn't want to print an error at the API level and instead print > at the caller level. But if that's what you want, that's fine by me. That would be fine, you can keep the print message here (but a generic one, like key missing). > > > - } else { > > > - /* > > > - * Rate is defined as an unsigned long in clk API, and so > > > - * casting explicitly to its type. Must be fixed once rate is 64 > > > - * bit guaranteed in clk API. > > > - */ > > > - new_opp->rate = (unsigned long)rate; > > > } > > > > > > of_property_read_u32(np, "opp-level", &new_opp->level); > > > diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h > > > index 01a500e2c40a..6bb238af9cac 100644 > > > --- a/drivers/opp/opp.h > > > +++ b/drivers/opp/opp.h > > > @@ -56,7 +56,8 @@ extern struct list_head opp_tables; > > > * @turbo: true if turbo (boost) OPP > > > * @suspend: true if suspend OPP > > > * @pstate: Device's power domain's performance state. > > > - * @rate: Frequency in hertz > > > + * @rate: Frequency in hertz OR Peak bandwidth in kilobytes per second > > > + * @avg_bw: Average bandwidth in kilobytes per second > > > > Please add separate entry for peak_bw here. > > > > I know you reused rate because you don't want to reimplement the helpers we > > have. Maybe we can just update them to return peak_bw when opp-hz isn't present. > > How about I just rename this to "key"? That makes a lot more sense > than trying to save 3 different keys and going through them one at a > time. I would still like to keep separate fields for now. We are still in continuous development and don't know how things will be going forward. We may end up having bw and hz in the OPP table as well. Over that I like to have separate fields for readability. Thanks. -- viresh