Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5924045ybh; Wed, 7 Aug 2019 13:54:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC6REcYgXos2Tj1B6MXxSt6btCg2sN/TZvUbts0LIEGoVeLA+THGFm+0/RkVsmrFk07I4U X-Received: by 2002:a62:2ccc:: with SMTP id s195mr11269344pfs.256.1565211273245; Wed, 07 Aug 2019 13:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565211273; cv=none; d=google.com; s=arc-20160816; b=T1lZqCYqXvVuUsgT4ZB0exJnQ/PeqgC6CmU+hu9TM9qS8RjnZhErnycsDBLU5E8bDg jUNOFdgFBucT8NlBZP0VxNpe0U7HgzCyrzaMGeuhUmvz5yiUocTw88zOlTzf8uzLyXU0 ihY53/3rHk5wl+BRlJmiG7z4X6nkIPflxhVGl3U/N0Wn6wm9b6uZu7IVKgW8Xw/83PUj fmWAbjki7XrHL7TgKHzRJ8w74HlXo9pYEMdJ6PzAVxyJ4D5WC8ZrPJKUqrnUVkvZ9gAf IPiJKwzl0kFXpM4P2Y+P8N4hvNzJ9TSnd18oNBqM66+zLe6oD7M6UpC+VdsKelgsAsQk v4gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1drnZsNJ30h8VB1p7exPq6Ba5yiKi2dka+MQPDhn2UQ=; b=S/67V4Jaez8krjActHUD6FrssPQZsEsRQFSLwYTKypWfjMBk6stD4YnMvPeE9Vq+1g nvtjwWKHMlKPacxt6BbtD8bk/2xeJzExBUloFWNgUC94ThXvBZFoRJDCzWLw7gy1dRXh qb9yMPKSogVLGrB9it6+liBoe2c6V9G94PHkKmv9m5NlhO984Tzolusy6kC7CB7utRGp 0RqCxQTxMHiXXa+zT61e8J3zk3axvEY8hgiePms1dOoKXIeQVQ5BpW65RKVQorkZ6cSX tj5vNN3Lk1YtOjKLp/2Uy/Pa65B+5c+OVF0x10BgnVmGqQXXPRYJ9OuqJUB6MDXNo4bP LgLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jWK9JgU9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q38si37041112pgk.63.2019.08.07.13.54.17; Wed, 07 Aug 2019 13:54:33 -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=@google.com header.s=20161025 header.b=jWK9JgU9; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389490AbfHGUqw (ORCPT + 99 others); Wed, 7 Aug 2019 16:46:52 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:36498 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730045AbfHGUqv (ORCPT ); Wed, 7 Aug 2019 16:46:51 -0400 Received: by mail-ot1-f66.google.com with SMTP id r6so109741297oti.3 for ; Wed, 07 Aug 2019 13:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1drnZsNJ30h8VB1p7exPq6Ba5yiKi2dka+MQPDhn2UQ=; b=jWK9JgU9V08mGULS627pv+JWIbES/c1ddmqDJQCSA18TSPZ65qxQOlPswgfzd06XFf DRuWrk80lcdXWpPZRX+lIiOY93ECSJoiQCGKN/wDU+EHHTbLZ8A9wjLZy2dhklRZT0SV ykhyFs4wnZb/eB8ScZ1OXkw5hUNFhxlruQsR0XTMfWapA9vp6BDhr992fOZ3AEoL2FLA lTbqUyJLr0fHXCfTQ5bhr8BrSoe2tf84CsXyxhWG3n/xTeJIcF9wZwunMgBBHsjHoYc3 1k3vEGC/zWh0DYG+xWHddiDWHVd0EVvrz8u2z/NZYuLxsh34HPkSdCGcEmk1//SEwzBY GK7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1drnZsNJ30h8VB1p7exPq6Ba5yiKi2dka+MQPDhn2UQ=; b=uB2aKxNFRvVMJTTl1+5C/4wKTeGpo/Paj2uALmKVtUXzu5MJwwTOJhNOGJo1H9rJ/i CnUfOPfsT69zCE52dlamNqIZnzCGaQpZ5jvhK8fz0qUUM/HUNNahoNPS3Z/+5/uX6Vbn 82jrA+Gg9z9OgFIrhb2W99ja5Pbe3l3DfjcjDpvLh0zkO5qU038HxiZcCYzKAsp8OR2R xvON7a7HFXkQlMdcPKdlJQdhN1WeSOOU/E6MXA0Xgl3O1CJcJfcRDmtNKH1uJ8uNnHLO kLafsIS0hvKZbVks8rlFWPPd0UsQwr+ngEk/FtuicGyVjOGiwSGRz2AtyK7fG2U0n5iY AdPw== X-Gm-Message-State: APjAAAXJ71QK6DQRPjcUJFAqGcEpPezaL5D8LurCoXUzPKpju1XiOZCv hZx9aJYsbHhtVYOK5SPx+1Gywz43GkfyjPPNWv2r4g== X-Received: by 2002:a9d:6256:: with SMTP id i22mr9805438otk.139.1565210810189; Wed, 07 Aug 2019 13:46:50 -0700 (PDT) MIME-Version: 1.0 References: <20190726231558.175130-1-saravanak@google.com> <20190726231558.175130-3-saravanak@google.com> In-Reply-To: From: Saravana Kannan Date: Wed, 7 Aug 2019 13:46:14 -0700 Message-ID: Subject: Re: [PATCH v4 2/3] OPP: Add support for bandwidth OPP tables To: Georgi Djakov Cc: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 7, 2019 at 5:53 AM Georgi Djakov wrote: > > Hi Saravana, > > On 7/27/19 02:15, 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 b313aca9894f..ac73512f4416 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; > > So we can't have a single OPP table with both frequency and bandwidth? Right, because we can have only 1 "key" for the OPP table. Having more than one "key" for an OPP table makes a lot of things pretty messy. Most of the helper functions need to be rewritten to say which key is being referred to when searching. A lot of the error checking when creating OPP tables becomes convoluted -- can we allow more than one OPP entry with the same frequency just because the opp-peak-kBps is different? Etc. Seems like a lot of code change for something that I don't think is a very useful. Also, an OPP table is either going to represent performance levels of a clock domain (opp-hz) or the performance levels of an interconnect path (opp-peak-kBps) or an OPP table for genpd. Mixing them all up is just going to make it convoluted with not enough benefit or use case that can't be handled as is (separate BW and freq OPP tables). > > + } > > + > > + 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; > > + > > + return 0; > > +} > > + > > /** > > * _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-bw not found\n", > > s/opp-peak-bw/opp-peak-kBps/ Thanks. Will fix. -Saravana