Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5264396ybi; Tue, 30 Jul 2019 17:22:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5DBdqbxM7d7rAPlgF/E5rv/yMWlwzw3xx0OxoZrN7txED+psfmXxfYMG8YaGzabKASQDI X-Received: by 2002:aa7:87d5:: with SMTP id i21mr44230310pfo.70.1564532567702; Tue, 30 Jul 2019 17:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564532567; cv=none; d=google.com; s=arc-20160816; b=zy0q7BIwze0MvaX5ZWLJrcVlqldYDanoAPrn6d4nzMOWzJ/9zDLglRXAaBijC3zQEx dYiC8tcAdiI0v/yeoo+22QpbjKdMXeVwfq3QtzYP/5ZhZwetemAnhIBRVFwYys1U3SfA neBXBOKyvQiumFCjZK2AOgLTfS2Q0MNWSkswEXRUm/dFHlMAXNrvSOXPySeby+N4KUEh UO+Qbr4XitlonvOpB0I6AL+Gjok4l/AnbEApo4/IswBWgrL1pHh6cdY+igRMdkieKFaD JgwwNbGpeL9NfljGgqSmcjzmhbWt0C+Fi3WwfQrn71+Cocouy2S7RxFJBU/jt+9ibeYR Zn5Q== 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=t68EXPEyPb2/r7j8LTsJ+u3l3tFbqRdeyuThoSQX0Z8=; b=UTMlWNTWrvjXyWUPWUa782FtYjsFc3QqjYkoccbZPK+4sDpt8ZBMODf3FdkQdsrLV8 aeTpmvgNnG18m6zE4+kfc1VuRmv0cxz/t3tl2V8vZnotefFsFlrP5wiFXP6sQSY/gC/M AqRq4srSK7KZRYyDWlslKDWPLKEqwAl8xSBW0I8Kf2sSFznaIW449W8q8IRCWypXw9xq 09y60un9wZsQc4xMRlB8aHXGWOD869A/60MetIjIZMA85DPzMoi4vyHkMMpLGwbdbtGp 7tRWQaKD6FIJEs1RhS5Qd6GrHSAiUPyRZp4OcBmvVBsL+iR8luHdY9jSNUkNej6z3Yul c4Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uM+oBlrX; 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 b4si31888059pfg.49.2019.07.30.17.22.33; Tue, 30 Jul 2019 17:22: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=@google.com header.s=20161025 header.b=uM+oBlrX; 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 S1727765AbfG3XVh (ORCPT + 99 others); Tue, 30 Jul 2019 19:21:37 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:33715 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbfG3XVh (ORCPT ); Tue, 30 Jul 2019 19:21:37 -0400 Received: by mail-ot1-f67.google.com with SMTP id q20so68092251otl.0 for ; Tue, 30 Jul 2019 16:21:36 -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=t68EXPEyPb2/r7j8LTsJ+u3l3tFbqRdeyuThoSQX0Z8=; b=uM+oBlrX9psFtPZuEZkbi0e4Vpn7VCy/YMTrHPulqmY/1qWEEVwhjuNGmHxf0E+HQb rrVW1W3yK4x96wQG6KFPEOMXHduMyfhAQI8JN0qpPDLRkrcCCIgVXsBuzLc5TUcz+K3T Xytm0P1ezA9fyvj74lY/B/scgzyuVwmiZgx6NTTkVY5m3nd5O9As83CCE5rfnmLc8C4D 4fjPHIMupHeP0Dj5o3dD+/fXTIW3YSjXyaZYfi9rhJNLh6j1deJZ7RO0iWXIII1Mx7nE VhZwiJeSFCWbeKH88s58QktIT6+OC4rNZm5C8a9ZaLSu3WqAoKh7sybL/QwFkQM6e7tx UzTQ== 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=t68EXPEyPb2/r7j8LTsJ+u3l3tFbqRdeyuThoSQX0Z8=; b=rfqDYs980lqrx60dM3uddwCzUtYGq8Ft0hAYeRGbw3clgXxi1kTJxvY+8yS2/I2415 x6pqjhqj57Cjb6mJrJOwpHw1rXzmG5IGcnSsXYWZZUKlHwG925rKoQ1DrLy7UE1wA8AD UteZ0o/qkntuUgMQW3hHqj/cdWYpPcLFkduWrvc1RN93a4UoRiEAqhPVgOhzzASG79B5 W3tue8NpfWuYkyhBeHT6Cnwib8VUywF1BejqwN8i75Aje95UVaAjb2TAYJ1F7cA8JcMI 02TQRtV6IUUNUuek03UDWilIi5ChJ0sKCa/pUhrlRf2jvjQbwjDyoZCkVCFs0lVSiaMi 5vhA== X-Gm-Message-State: APjAAAVXnjjfBpum5ZQqldJ25OBODYGnul8OQLmEHI1Tq0HH36pqDSza OvUsNKrrWmwgjUenCu024f/WPFqM/lC6SBUfEOSADg== X-Received: by 2002:a9d:6201:: with SMTP id g1mr89652643otj.195.1564528895800; Tue, 30 Jul 2019 16:21:35 -0700 (PDT) MIME-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> <20190703011020.151615-3-saravanak@google.com> In-Reply-To: From: Saravana Kannan Date: Tue, 30 Jul 2019 16:20:59 -0700 Message-ID: Subject: Re: [PATCH v3 2/6] OPP: Add support for bandwidth OPP tables To: Amit Kucheria Cc: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Vincent Guittot , "Sweeney, Sean" , David Dai , Rajendra Nayak , Sibi Sankar , Bjorn Andersson , Evan Green , Android Kernel Team , Linux PM list , "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 Tue, Jul 30, 2019 at 3:57 AM Amit Kucheria wrote: > > On Wed, Jul 3, 2019 at 6:40 AM 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 | 34 ++++++++++++++++++++++++++++++++-- > > drivers/opp/opp.h | 4 +++- > > 2 files changed, 35 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/opp/of.c b/drivers/opp/of.c > > index c10c782d15aa..54fa70ed2adc 100644 > > --- a/drivers/opp/of.c > > +++ b/drivers/opp/of.c > > @@ -552,6 +552,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; > > + } > > + > > + 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 > > @@ -589,11 +618,12 @@ 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", > > + __func__); > > goto free_opp; > > } > > > > diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h > > index 569b3525aa67..ead2cdafe957 100644 > > --- a/drivers/opp/opp.h > > +++ b/drivers/opp/opp.h > > @@ -59,7 +59,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 > > rate is most often used for clk rates. Let us not overload this just > to save one struct member. IMO, you should introduce a peak_bw member > and then have an error check if the DT provides both rate and peak_bw > during parsing. This is not about saving space. It avoids having to rewrite a lot of helper functions. If you want, I can rename this to "key" but I'm not going to create a different field. -Saravana