All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Saravana Kannan <saravanak@google.com>
Cc: MyungJoo Ham <myungjoo.ham@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Sibi Sankar <sibis@codeaurora.org>,
	Android Kernel Team <kernel-team@android.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 3/5] OPP: Improve require-opps linking
Date: Mon, 29 Jul 2019 12:56:12 +0530	[thread overview]
Message-ID: <20190729072612.pdxoguwheawtrf6d@vireshk-i7> (raw)
In-Reply-To: <CAGETcx9UAAc6u=qFPN49Pn2u4xiMCroL-PhHqLZrBPRSXBbHBw@mail.gmail.com>

On 26-07-19, 14:23, Saravana Kannan wrote:
> I was taking a closer look at the OPP framework code to try and do
> what you ask above, but it's kind of a mess. The whole "the same OPP
> table can be used by multiple devices without the opp-shared flag set"
> is effectively breaking "required-opps" at a minimum and probably a
> lot more cases. I don't think I can rewrite my patch the way you want
> it without fixing the existing bugs.
> 
> Let's take this example DT (leaving out the irrelevant part):
> 
> OPP table 1:
>     required-opps = <OPP table 2 entry>;
> 
> OPP table 2:
>     <opp-shared property not set>
> 
> Device A:
>     operating-points-v2 = <&OPP table 1>
> 
> Device B:
>     operating-points-v2 = <&OPP table 2>
> 
> Device C:
>     operating-points-v2 = <&OPP table 2>
> 
> Let's say device B and C add their OPP tables. They both get their own
> "in-memory" copy of the OPP table. They can then enabled/disable
> different OPP entries (rows) and not affect each other's OPP table.
> Which is how it's expected to work.
> 
> Now if device A adds its OPP table 1, the "in-memory"
> required_opp_tables pointer of OPP table 1 can end up pointing to
> either Device A's copy of the OPP table or Device B's copy of the OPP
> table depending on which happens to be added first. This effectively
> random linking of OPP tables is mutually exclusive to the point of
> required-opps.

> Also, at a DT definition level, OPP table 1 pointing to OPP table 2
> when OPP table 2 is used by more than one device doesn't make any
> sense. Which device/genpd is OPP table 1 saying it "requires to
> operate at a certain level"?

I will say that this data is present at least for the present set of
users, i.e. power domains. Just that it isn't present so directly
within the OPP table. But if you look at the device's node, it will
point you to some power domain, etc.

I didn't do anything about it earlier because it required more work
and I thought "required-opps" property is there to get us some data
and it does get that data to us right now. Just that we don't know the
device for which this data is there in the OPP core.

If we do want to get this linking, how should we get it ?

- Using another property in device's DT node, like
  "required-opp-devices" ? I didn't like it earlier because that would
  be like duplicating data we already had for the power domains.

- Using some in-kernel function, using which other drivers can give us
  this data ? Maybe yes. Probably that's the best way of doing it ?

> So I propose that we should consider the OPP table DT configuration
> invalid if one OPP table points to another OPP tables that's NOT
> shared but is ALSO pointed to by multiple devices. Basically the
> example above would be considered an invalid DT configuration. Does
> that sound okay to you? If I make changes to enforce that, will that
> be acceptable?

I don't think that would be the right thing to do as the idea of
sharing the DT OPP tables to avoid duplicate tables in DT was the
correct thing to do and is getting used very much right now as well.

Perhaps we should fix the problem instead.

> If this sounds okay to you, then in the example above, assume Device C
> isn't present. Then when OPP table 1 is added by device A, if OPP
> table 2 hasn't been added already, I can just go ahead and allocate
> OPP table 2. And then when device B tries to add OPP table 2, I can
> just tie device B to OPP table 2 and fill up any of the missing
> pieces.

I can assure you that it would be a big mess. Specially the reference
counting using which we free OPP tables and OPPs right now will come
in your way.

> This sounds better than trying to loop through existing OPP tables and
> seeing if any other table is waiting for the newly added table and
> marking the waiting tables as "linked". Especially because it gets a
> lot more complicated and inefficient when you consider a chain of OPP
> tables and many-to-many linking of OPP tables.

Firstly, this is all going to be initialization code and will not run
after boot normally. And we will probably not have very complex
linking cases as well I believe. Maybe 2-3 levels at the best. And
this will keep code much simpler compared to the above idea.

So here is the thing. I think you should separate out the lazy-linking
thing from this patchset as this is a completely different problem you
are trying to solve and is unnecessarily blocking other patches.

And if you don't want to get into solving the lazy linking thing
yourself, because that is consuming your time unnecessarily, then I
can see if I can put some of my cycles on it.

-- 
viresh

  reply	other threads:[~2019-07-29  7:26 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 22:23 [PATCH v3 0/5] Add required-opps support to devfreq passive gov Saravana Kannan
2019-07-17 22:23 ` [PATCH v3 1/5] OPP: Allow required-opps even if the device doesn't have power-domains Saravana Kannan
2019-07-17 22:23 ` [PATCH v3 2/5] OPP: Add function to look up required OPP's for a given OPP Saravana Kannan
2019-07-23  9:53   ` Viresh Kumar
2019-07-24  0:23     ` Saravana Kannan
2019-07-25  2:58       ` Viresh Kumar
2019-07-25  3:46         ` Saravana Kannan
2019-07-25  5:38           ` Viresh Kumar
2019-07-26  1:41             ` Saravana Kannan
2019-07-17 22:23 ` [PATCH v3 3/5] OPP: Improve require-opps linking Saravana Kannan
2019-07-23 10:28   ` Viresh Kumar
2019-07-23 20:36     ` Saravana Kannan
     [not found]     ` <CAGETcx-6M9Ts8tfMf6aA8GjMyzK5sOLr069ZCxTG7RHMFPLzHw@mail.gmail.com>
2019-07-25  3:07       ` Viresh Kumar
2019-07-25  4:09         ` Saravana Kannan
2019-07-25  5:17           ` Viresh Kumar
2019-07-26  1:52             ` Saravana Kannan
2019-07-26 21:23               ` Saravana Kannan
2019-07-29  7:26                 ` Viresh Kumar [this message]
2019-07-30 23:02   ` Hsin-Yi Wang
2019-07-30 23:05     ` Saravana Kannan
2019-11-25 11:28   ` Viresh Kumar
2019-11-25 11:29     ` Viresh Kumar
2019-12-05 19:11       ` Saravana Kannan
2019-12-10  5:21         ` Viresh Kumar
2020-01-27  6:11     ` Viresh Kumar
2020-01-29 13:34       ` Sibi Sankar
2020-01-30  4:21         ` Viresh Kumar
2021-01-18  7:21           ` Hsin-Yi Wang
2021-01-18  7:34             ` Viresh Kumar
2021-01-18  7:39               ` Hsin-Yi Wang
2021-01-20  0:05                 ` Saravana Kannan
2021-01-27 11:54                 ` Viresh Kumar
2021-01-27 14:40                   ` Hsin-Yi Wang
2021-01-28  4:13                     ` Viresh Kumar
2021-01-28  5:05                       ` Hsin-Yi Wang
2019-07-17 22:23 ` [PATCH v3 4/5] PM / devfreq: Cache OPP table reference in devfreq Saravana Kannan
2019-07-17 22:23 ` [PATCH v3 5/5] PM / devfreq: Add required OPPs support to passive governor Saravana Kannan
2019-07-23 10:04   ` Viresh Kumar
2019-07-24  0:26     ` Saravana Kannan
2019-07-25  3:01       ` Viresh Kumar
2019-07-25  3:58         ` Saravana Kannan

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=20190729072612.pdxoguwheawtrf6d@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=cw00.choi@samsung.com \
    --cc=kernel-team@android.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=nm@ti.com \
    --cc=rjw@rjwysocki.net \
    --cc=saravanak@google.com \
    --cc=sboyd@kernel.org \
    --cc=sibis@codeaurora.org \
    --cc=vireshk@kernel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.