Linux-ARM-MSM Archive on lore.kernel.org
 help / color / Atom feed
From: Saravana Kannan <saravanak@google.com>
To: Mike Tipton <mdtipton@codeaurora.org>
Cc: Georgi Djakov <georgi.djakov@linaro.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	okukatla@codeaurora.org,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-arm-msm <linux-arm-msm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] interconnect: Add sync state support
Date: Thu, 30 Jul 2020 12:07:20 -0700
Message-ID: <CAGETcx-i=wBB4Ooch734B0ejK6F5mGPLQ6c_K4FeFyNmMLsL=Q@mail.gmail.com> (raw)
In-Reply-To: <e4f68ae5-5cf7-bac4-e7f2-c074327ea659@codeaurora.org>

On Mon, Jul 27, 2020 at 11:18 PM Mike Tipton <mdtipton@codeaurora.org> wrote:
>
> On 7/22/2020 10:07 AM, Saravana Kannan wrote:
> > On Wed, Jul 22, 2020 at 4:01 AM Georgi Djakov <georgi.djakov@linaro.org> wrote:
> >>
> >> The bootloaders often do some initial configuration of the interconnects
> >> in the system and we want to keep this configuration until all consumers
> >> have probed and expressed their bandwidth needs. This is because we don't
> >> want to change the configuration by starting to disable unused paths until
> >> every user had a chance to request the amount of bandwidth it needs.
> >>
> >> To accomplish this we will implement an interconnect specific sync_state
> >> callback which will synchronize (aggregate and set) the current bandwidth
> >> settings when all consumers have been probed.
> >>
> >> Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
> >> ---
> >>   drivers/interconnect/core.c           | 61 +++++++++++++++++++++++++++
> >>   include/linux/interconnect-provider.h |  5 +++
> >>   2 files changed, 66 insertions(+)
> >>
> >> diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c
> >> index e5f998744501..0c4e38d9f1fa 100644
> >> --- a/drivers/interconnect/core.c
> >> +++ b/drivers/interconnect/core.c
> >> @@ -26,6 +26,8 @@
> >>
> >>   static DEFINE_IDR(icc_idr);
> >>   static LIST_HEAD(icc_providers);
> >> +static int providers_count;
> >> +static bool synced_state;
> >>   static DEFINE_MUTEX(icc_lock);
> >>   static struct dentry *icc_debugfs_dir;
> >>
> >> @@ -255,6 +257,12 @@ static int aggregate_requests(struct icc_node *node)
> >>                          continue;
> >>                  p->aggregate(node, r->tag, r->avg_bw, r->peak_bw,
> >>                               &node->avg_bw, &node->peak_bw);
> >> +
> >> +               /* during boot use the initial bandwidth as a floor value */
> >> +               if (!synced_state) {
> >> +                       node->avg_bw = max(node->avg_bw, node->init_avg);
> >> +                       node->peak_bw = max(node->peak_bw, node->init_peak);
> >> +               }
> >
> > Sorry I didn't reply earlier.
> >
> > I liked your previous approach with the get_bw ops. The v2 approach
> > forces every interconnect provider driver to set up these values even
> > if they are okay with just maxing out the bandwidth. Also, if they can
> > actually query their hardware, this adds additional steps for them.
>
> The problem with using something like get_bw() is that while we can
> dynamically query the HW, we have far less granularity in HW than we
> have nodes in the framework. We vote at BCM-level granularity, but each
> BCM can have many nodes. For example, the sdm845 CN0 BCM has 47 nodes.
> If we implement get_bw() generically, then it would return the BW for
> each node, which would be the queried BCM vote scaled to account for
> differences in BCM/node widths. While this could be useful in general as
> an informational callback, we wouldn't want to use this as a proxy for
> our initial BW vote requirements. For CN0, we wouldn't want or need to
> vote 47 times for the same CN0 BCM. Each of the 47 node requests would
> result in the same BCM request.

Firstly most people in the list don't know what BCM means. Also, all
of this is your provider driver specific issues. If you are exposing
more nodes than available HW granularity, then you might want to
question why it needs to be done (probably to make aggregation easier
for the driver). If it's needed, then optimize your get/set() calls by
caching the value in an internal variable so that you don't send a
request to your BCM if you haven't changed the value since the last
request. This is not a reason to not have get_bw() calls at the
framework level. Other providers might support it and it'd make their
lives easier.

> All we'd really need is a single node per-BCM to serve as the proxy
> node. We'd query the HW, scale the queried value for the chosen proxy
> node, and set init_avg/init_peak appropriately. This would save a lot of
> unnecessary votes. Based on the current implementation, the set() call
> in icc_node_add() for initial BW wouldn't trigger any actual HW requests
> since we only queue BCMs that require updating in the aggregate()
> callback. However, the set() call in icc_sync_state() would, since we
> re-aggregate each node that has a non-zero init_avg/init_peak.

Having a fake "proxy node" seems like a bad internal design. Also,
have you timed the cost of these calls to justify your concern? If you
cache the values after aggregation and check before you send it down
to a "BCM", at worst you get one additional call to rpmh per BCM due
to this feature. I'm guessing any time delta would be lost as noise
compared to the boot up time.

> There's nothing stopping us from implementing get_bw() as if it were
> get_initial_bw(), but that only works until the framework decides to use
> get_bw() for more things than just the initial vote. I suppose we could
> also just have a "get_initial_bw" callback, but it only needs to be
> called once, so doesn't necessarily need a callback as opposed to
> additional init_avg/init_peak members in the icc_node struct.

The benefit of "ops" vs "fill up these variables" is that you can
differentiate between "I don't care, framework can decide" vs "I need
it to be 0". Put another way, there's no way to say "I don't care" if
you use variables. And by default drivers that don't really care (as
in, okay if it's set to INT_MAX) shouldn't have to do extra code/work.

Long story short, there's nothing wrong with get_bw(). If your
specific driver needs to optimize the calls to your RPMH hardware,
that should be hidden inside your driver.

-Saravana

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-22 11:01 [PATCH v2 0/2] Add interconnect " Georgi Djakov
2020-07-22 11:01 ` [PATCH v2 1/2] interconnect: Add " Georgi Djakov
2020-07-22 17:07   ` Saravana Kannan
2020-07-28  6:18     ` Mike Tipton
2020-07-30 19:07       ` Saravana Kannan [this message]
2020-08-01  2:36         ` Mike Tipton
2020-07-22 11:01 ` [PATCH v2 2/2] interconnect: qcom: Use icc_sync_state in sdm845 and osm-3l drivers Georgi Djakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGETcx-i=wBB4Ooch734B0ejK6F5mGPLQ6c_K4FeFyNmMLsL=Q@mail.gmail.com' \
    --to=saravanak@google.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=georgi.djakov@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mdtipton@codeaurora.org \
    --cc=okukatla@codeaurora.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-ARM-MSM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-msm/0 linux-arm-msm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-msm linux-arm-msm/ https://lore.kernel.org/linux-arm-msm \
		linux-arm-msm@vger.kernel.org
	public-inbox-index linux-arm-msm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-arm-msm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git