Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4609174ybi; Tue, 30 Jul 2019 05:08:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyX/+p/crir5whu3FOs+Y9QqmBZ3JNNj3eAoPNMQL6FrstgSrYo+8Rx1naA5eGlcxv1evS7 X-Received: by 2002:a65:52ca:: with SMTP id z10mr58961638pgp.424.1564488500618; Tue, 30 Jul 2019 05:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564488500; cv=none; d=google.com; s=arc-20160816; b=eO/YzaTDmPVwftcjOI6pN+DBp4ZdmJJ0fm/dtWXKfecnp0ozG/J5KwPQd7kqEB+da3 PTMSJ0bZBrVZd1ImRk3AoHp27v4tIbOpBZfWusoaw2YEhrZbXpyPvm9p9vzoU8I8qK5X WG+YDDX363dHXj9tIjIcS+l3jDAvAaBCHhcf6eIenD3rF/O3/d9Z75/jnxcrfNtl5jlt iBMhGOYE9xstYr99PgMoGjEgxRx+fbWQ3+QFwAn8YPvW4nDZIT7EhsUxRgZY+wQ6cDEa d96FiP3BtRBiJmz6uOLjnkzghROYKmU06u6btEpPoCVJGsnMq7+bj6U7wZwQr3uMJ+mB Om/g== 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=PU2Fv6R/P/i3mcSRuoPPGRfAr6wNs2iQGjXmUbGxWxs=; b=QetEFxFfPFYqNREbiAr5kcR0oDsBRHk/5RVWtBppKnPN2I1Cn7/9kLKcXV7DvJazx8 eAqaxlKP/KB0l8T4U5MkZlv9WQmoKtEK4BMhZ+T8qOEx8UVhGOd/uJcmfbQJjqRetP+e QdR2OTNIvL3l9h9Mbu/4ZH3sprD5XRuIlF4F7w//XyV1umvRC8AVXDIkPhe2OB85HkWh 4qsxw4kcdGPwVE//dJOAE01Ef7p3EZ0nDrknyTeEMIU1Ut5OY+Ml6sZf7NaspAki52lN Z3O6d5RzLsu5vVzPqOc905TCe2haa1UHXid/jON5NVdqRoi5A7v1fH01L7lZZw0YPBGx KWZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lkRzDG3p; 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 70si27149189plc.253.2019.07.30.05.08.04; Tue, 30 Jul 2019 05:08:20 -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=lkRzDG3p; 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 S1729291AbfG3K51 (ORCPT + 99 others); Tue, 30 Jul 2019 06:57:27 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:42495 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727445AbfG3K51 (ORCPT ); Tue, 30 Jul 2019 06:57:27 -0400 Received: by mail-vs1-f66.google.com with SMTP id 190so43144845vsf.9 for ; Tue, 30 Jul 2019 03:57:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PU2Fv6R/P/i3mcSRuoPPGRfAr6wNs2iQGjXmUbGxWxs=; b=lkRzDG3pOo++tgaJ/bk6mpSVrJ4U+eY8OcNTWGQUVYUYttxgttg75uet9SsFVlFj5X 56vVKNNShTVrkciES8RZLgERCq6Eu0inKgLrUXv+UHknTTkko1Me/AOYQaVhrvr9ul74 k1ZTN/KKq9M1A97FcfnuCHs66ezrP2LfZjt5Jh4mNTvBZ+Qa5vBvXihKX09g1pwef9ah 1RwV0XnWUyYYde3qxBhhETbVOtbuTv60HpbxbZL2DhePWYOkqd7U1ATi3lvbR2YHhSiJ BqxzRofIdR8rdaLCo1QBqSHc2QbtkbxrWoMWZkIvC311uMEgvbJ1WhFqqUpQRgGI02/r jRKg== 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=PU2Fv6R/P/i3mcSRuoPPGRfAr6wNs2iQGjXmUbGxWxs=; b=Ny+xaNTWN9LENDBZlfdnDkcmN53hYlC41Vqvdn+57X2WXZ7yix2gJDg0QQwWyiGZ7x mU2F+294yKae6bxdTKm9ltOHLumyiRjDrbtKpsC0rPTqnWQAhTeJTMmQUOEflRcW31Pz 3aC3dLqsosvv3aRcIqz0qj2MABiNFgf+p7OrJxf0JzbtBLngI2l0Hk3KsEnRC5BLE1vz UsgGn+G4GSJQ+D2nM+jJWEXUNvMDjtQGH/vlFGbUIE4Fu4FiYB5MlV8SPImH8pKz30xj RJwlfuJMT6kxNIKQeGpNXUfJ72HhBFydOctyTz8zyGD54gEBVFe+Jc8Qimirueg+L/Rh Owpg== X-Gm-Message-State: APjAAAVUuMfa6loR8FAwvCPSKOE+TXHos8N/yfguBkP5sLYgo1oGC1A3 m2HLyCWONDWq1mCT4hNv/cTRgpV8ZRPZpH0y+7Q= X-Received: by 2002:a67:fb87:: with SMTP id n7mr42648957vsr.9.1564484245706; Tue, 30 Jul 2019 03:57:25 -0700 (PDT) MIME-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> <20190703011020.151615-3-saravanak@google.com> In-Reply-To: <20190703011020.151615-3-saravanak@google.com> From: Amit Kucheria Date: Tue, 30 Jul 2019 16:27:14 +0530 Message-ID: Subject: Re: [PATCH v3 2/6] OPP: Add support for bandwidth OPP tables To: Saravana Kannan Cc: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" , Vincent Guittot , seansw@qti.qualcomm.com, daidavid1@codeaurora.org, Rajendra Nayak , Sibi Sankar , Bjorn Andersson , evgreen@chromium.org, kernel-team@android.com, 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 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. > + * @avg_bw: Average bandwidth in kilobytes per second > * @level: Performance level > * @supplies: Power supplies voltage/current values > * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's > @@ -81,6 +82,7 @@ struct dev_pm_opp { > bool suspend; > unsigned int pstate; > unsigned long rate; > + unsigned long avg_bw; > unsigned int level; > > struct dev_pm_opp_supply *supplies; > -- > 2.22.0.410.gd8fdbe21b5-goog >