Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-25 Thread Viresh Kumar
On 26-08-21, 08:24, Viresh Kumar wrote: > On 25-08-21, 18:41, Dmitry Osipenko wrote: > > Thinking a bit more about this, I got a nicer variant which actually works > > in all cases for Tegra. > > > > Viresh / Ulf, what do you think about this: > > This is what I have been suggesting from day 1 :

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-25 Thread Viresh Kumar
On 25-08-21, 18:41, Dmitry Osipenko wrote: > Thinking a bit more about this, I got a nicer variant which actually works in > all cases for Tegra. > > Viresh / Ulf, what do you think about this: This is what I have been suggesting from day 1 :) https://lore.kernel.org/linux-staging/2021081805584

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-25 Thread Dmitry Osipenko
22.08.2021 21:35, Dmitry Osipenko пишет: > 20.08.2021 08:18, Viresh Kumar пишет: >> On 19-08-21, 16:55, Ulf Hansson wrote: >>> Right, that sounds reasonable. >>> >>> We already have pm_genpd_opp_to_performance_state() which translates >>> an OPP to a performance state. This function invokes the >>>

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-23 Thread Viresh Kumar
On 23-08-21, 23:24, Dmitry Osipenko wrote: > It's not clear to me whether it will be okay to add a generic OPP syncing by > clock rate or should it be a Tegra-specific helper. Viresh, what do you think > about this generic OPP helper: > > /** > * dev_pm_opp_sync_with_clk_rate() - Sync OPP state

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-23 Thread Dmitry Osipenko
20.08.2021 15:57, Ulf Hansson пишет: ... >> We already have similar APIs, so that won't be a problem. We also have >> a mechanism inside the OPP core, frequency based, which is used to >> guess the current OPP. Maybe we can enhance and use that directly >> here. > > After reading the last reply fr

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-23 Thread Dmitry Osipenko
23.08.2021 13:46, Ulf Hansson пишет: >>> ... >>> dev_pm_opp_set_rate(rate) >>> pm_runtime_get_noresume() >>> pm_runtime_set_active() >>> pm_runtime_enable() >>> ... >>> pm_runtime_put() >>> ... >>> >>> We need to call genpd_set_performance_state() independently of whether >>> the device is runtime

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-23 Thread Ulf Hansson
[...] > We have three components comprising PM on Tegra: > > 1. Power gate > 2. Clock state > 3. Voltage state > > GENPD on/off represents the 'power gate'. > > Clock and reset are controlled by device drivers using clk and rst APIs. > > Volta

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-22 Thread Dmitry Osipenko
20.08.2021 08:18, Viresh Kumar пишет: > On 19-08-21, 16:55, Ulf Hansson wrote: >> Right, that sounds reasonable. >> >> We already have pm_genpd_opp_to_performance_state() which translates >> an OPP to a performance state. This function invokes the >> ->opp_to_performance_state() for a genpd. Maybe

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-21 Thread Dmitry Osipenko
20.08.2021 15:42, Ulf Hansson пишет: > On Thu, 19 Aug 2021 at 21:35, Dmitry Osipenko wrote: >> >> 19.08.2021 16:07, Ulf Hansson пишет: >>> On Wed, 18 Aug 2021 at 17:43, Dmitry Osipenko wrote: 18.08.2021 13:08, Ulf Hansson пишет: > On Wed, 18 Aug 2021 at 11:50, Viresh Kumar > w

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-20 Thread Ulf Hansson
On Fri, 20 Aug 2021 at 07:18, Viresh Kumar wrote: > > On 19-08-21, 16:55, Ulf Hansson wrote: > > Right, that sounds reasonable. > > > > We already have pm_genpd_opp_to_performance_state() which translates > > an OPP to a performance state. This function invokes the > > ->opp_to_performance_state()

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-20 Thread Ulf Hansson
On Thu, 19 Aug 2021 at 21:35, Dmitry Osipenko wrote: > > 19.08.2021 16:07, Ulf Hansson пишет: > > On Wed, 18 Aug 2021 at 17:43, Dmitry Osipenko wrote: > >> > >> 18.08.2021 13:08, Ulf Hansson пишет: > >>> On Wed, 18 Aug 2021 at 11:50, Viresh Kumar > >>> wrote: > > On 18-08-21, 11:41, U

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-19 Thread Viresh Kumar
On 19-08-21, 16:55, Ulf Hansson wrote: > Right, that sounds reasonable. > > We already have pm_genpd_opp_to_performance_state() which translates > an OPP to a performance state. This function invokes the > ->opp_to_performance_state() for a genpd. Maybe we need to allow a > genpd to not have ->opp

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-19 Thread Viresh Kumar
On 19-08-21, 22:35, Dmitry Osipenko wrote: > 19.08.2021 16:07, Ulf Hansson пишет: > > In the other scenario where a consumer driver prefers to *not* call > > pm_runtime_resume_and_get() in its ->probe(), because it doesn't need > > to power on the device to complete probing, then we don't want to v

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-19 Thread Dmitry Osipenko
19.08.2021 16:07, Ulf Hansson пишет: > On Wed, 18 Aug 2021 at 17:43, Dmitry Osipenko wrote: >> >> 18.08.2021 13:08, Ulf Hansson пишет: >>> On Wed, 18 Aug 2021 at 11:50, Viresh Kumar wrote: On 18-08-21, 11:41, Ulf Hansson wrote: > On Wed, 18 Aug 2021 at 11:14, Viresh Kumar > wr

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-19 Thread Ulf Hansson
On Thu, 19 Aug 2021 at 08:17, Viresh Kumar wrote: > > On 18-08-21, 18:55, Dmitry Osipenko wrote: > > 18.08.2021 12:41, Ulf Hansson пишет: > > > > Either way gives the equal result. The new callback allows to remove the > > boilerplate dev_pm_opp_set_rate(clk_get_rate() code from the rpm-resume > >

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-19 Thread Ulf Hansson
On Wed, 18 Aug 2021 at 17:43, Dmitry Osipenko wrote: > > 18.08.2021 13:08, Ulf Hansson пишет: > > On Wed, 18 Aug 2021 at 11:50, Viresh Kumar wrote: > >> > >> On 18-08-21, 11:41, Ulf Hansson wrote: > >>> On Wed, 18 Aug 2021 at 11:14, Viresh Kumar > >>> wrote: > What we need here is just con

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Viresh Kumar
On 18-08-21, 18:55, Dmitry Osipenko wrote: > 18.08.2021 12:41, Ulf Hansson пишет: > > Either way gives the equal result. The new callback allows to remove the > boilerplate dev_pm_opp_set_rate(clk_get_rate() code from the rpm-resume > of consumer devices, that's it. It may not be equal, as dev_pm

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Dmitry Osipenko
18.08.2021 12:41, Ulf Hansson пишет: > On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: >> >> On 18-08-21, 10:29, Ulf Hansson wrote: >>> Me and Dmitry discussed adding a new genpd callback for this. I agreed >>> that it seems like a reasonable thing to add, if he insists. Either way gives the eq

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Dmitry Osipenko
18.08.2021 18:43, Dmitry Osipenko пишет: > 18.08.2021 13:08, Ulf Hansson пишет: >> On Wed, 18 Aug 2021 at 11:50, Viresh Kumar wrote: >>> >>> On 18-08-21, 11:41, Ulf Hansson wrote: On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: > What we need here is just configure. So something like t

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Dmitry Osipenko
18.08.2021 13:08, Ulf Hansson пишет: > On Wed, 18 Aug 2021 at 11:50, Viresh Kumar wrote: >> >> On 18-08-21, 11:41, Ulf Hansson wrote: >>> On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: What we need here is just configure. So something like this then: - genpd->get_performance_sta

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Ulf Hansson
On Wed, 18 Aug 2021 at 11:50, Viresh Kumar wrote: > > On 18-08-21, 11:41, Ulf Hansson wrote: > > On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: > > > What we need here is just configure. So something like this then: > > > > > > - genpd->get_performance_state() > > > -> dev_pm_opp_get_current

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Viresh Kumar
On 18-08-21, 11:41, Ulf Hansson wrote: > On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: > > What we need here is just configure. So something like this then: > > > > - genpd->get_performance_state() > > -> dev_pm_opp_get_current_opp() //New API > > -> dev_pm_genpd_set_performance_state(dev,

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Ulf Hansson
On Wed, 18 Aug 2021 at 11:41, Ulf Hansson wrote: > > On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: > > > > On 18-08-21, 10:29, Ulf Hansson wrote: > > > Me and Dmitry discussed adding a new genpd callback for this. I agreed > > > that it seems like a reasonable thing to add, if he insists. > >

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Ulf Hansson
On Wed, 18 Aug 2021 at 11:14, Viresh Kumar wrote: > > On 18-08-21, 10:29, Ulf Hansson wrote: > > Me and Dmitry discussed adding a new genpd callback for this. I agreed > > that it seems like a reasonable thing to add, if he insists. > > > > The intent was to invoke the new callback from __genpd_de

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Viresh Kumar
On 18-08-21, 10:29, Ulf Hansson wrote: > Me and Dmitry discussed adding a new genpd callback for this. I agreed > that it seems like a reasonable thing to add, if he insists. > > The intent was to invoke the new callback from __genpd_dev_pm_attach() > when the device has been attached to its genpd

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-18 Thread Ulf Hansson
On Wed, 18 Aug 2021 at 08:27, Viresh Kumar wrote: > > On 18-08-21, 09:22, Dmitry Osipenko wrote: > > 18.08.2021 08:58, Viresh Kumar пишет: > > > What about calling dev_pm_opp_set_rate(dev, clk_get_rate(dev)) here > > > instead ? That will work, right ? The advantage is it works without > > > any s

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 09:22, Dmitry Osipenko wrote: > 18.08.2021 08:58, Viresh Kumar пишет: > > What about calling dev_pm_opp_set_rate(dev, clk_get_rate(dev)) here > > instead ? That will work, right ? The advantage is it works without > > any special routine to do so. > > It will work, but a dedicated hel

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 08:58, Viresh Kumar пишет: > On 18-08-21, 08:21, Dmitry Osipenko wrote: >> Yes, GENPD will cache the perf state across suspend/resume and initially >> cached value is out of sync with h/w. >> >> Nothing else. But let me clarify it all again. > > Thanks for your explanation. > >> Initia

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 11:28, Viresh Kumar wrote: > On 18-08-21, 08:21, Dmitry Osipenko wrote: > > Yes, GENPD will cache the perf state across suspend/resume and initially > > cached value is out of sync with h/w. > > > > Nothing else. But let me clarify it all again. > > Thanks for your explanation. > >

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 08:21, Dmitry Osipenko wrote: > Yes, GENPD will cache the perf state across suspend/resume and initially > cached value is out of sync with h/w. > > Nothing else. But let me clarify it all again. Thanks for your explanation. > Initially the performance state of all GENPDs is 0 for a

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 07:53, Viresh Kumar пишет: > On 18-08-21, 07:37, Dmitry Osipenko wrote: >> This will set voltage level without having an actively used hardware. >> Take a 3d driver for example, if you set the rate on probe and >> rpm-resume will never be called, then the voltage will be set high, >> whi

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 07:37, Dmitry Osipenko wrote: > This will set voltage level without having an actively used hardware. > Take a 3d driver for example, if you set the rate on probe and > rpm-resume will never be called, then the voltage will be set high, > while hardware is kept suspended if userspace w

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 07:31, Viresh Kumar пишет: > On 18-08-21, 07:12, Dmitry Osipenko wrote: >> 18.08.2021 06:55, Viresh Kumar пишет: >>> On 17-08-21, 18:49, Dmitry Osipenko wrote: 17.08.2021 10:55, Viresh Kumar пишет: ... >> +int dev_pm_opp_sync(struct device *dev) >> +{ >> +st

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 07:30, Dmitry Osipenko wrote: > 18.08.2021 07:29, Dmitry Osipenko пишет: > >> The first resume initializes the OPP state on sync, all further syncs on > >> resume are no-ops. > >> > > > > Notice that we use GENPD here. GENPD core takes care of storing PD's > > performance state (volta

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 18-08-21, 07:12, Dmitry Osipenko wrote: > 18.08.2021 06:55, Viresh Kumar пишет: > > On 17-08-21, 18:49, Dmitry Osipenko wrote: > >> 17.08.2021 10:55, Viresh Kumar пишет: > >> ... > +int dev_pm_opp_sync(struct device *dev) > +{ > +struct opp_table *opp_table; > +

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 07:29, Dmitry Osipenko пишет: > 18.08.2021 07:12, Dmitry Osipenko пишет: >> 18.08.2021 06:55, Viresh Kumar пишет: >>> On 17-08-21, 18:49, Dmitry Osipenko wrote: 17.08.2021 10:55, Viresh Kumar пишет: ... >> +int dev_pm_opp_sync(struct device *dev) >> +{ >> +s

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 07:12, Dmitry Osipenko пишет: > 18.08.2021 06:55, Viresh Kumar пишет: >> On 17-08-21, 18:49, Dmitry Osipenko wrote: >>> 17.08.2021 10:55, Viresh Kumar пишет: >>> ... > +int dev_pm_opp_sync(struct device *dev) > +{ > + struct opp_table *opp_table; > + struct dev_pm_opp *op

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
18.08.2021 06:55, Viresh Kumar пишет: > On 17-08-21, 18:49, Dmitry Osipenko wrote: >> 17.08.2021 10:55, Viresh Kumar пишет: >> ... +int dev_pm_opp_sync(struct device *dev) +{ + struct opp_table *opp_table; + struct dev_pm_opp *opp; + int ret = 0; + + /* Device

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 17-08-21, 18:49, Dmitry Osipenko wrote: > 17.08.2021 10:55, Viresh Kumar пишет: > ... > >> +int dev_pm_opp_sync(struct device *dev) > >> +{ > >> + struct opp_table *opp_table; > >> + struct dev_pm_opp *opp; > >> + int ret = 0; > >> + > >> + /* Device may not have OPP table */ > >> + opp_tab

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Dmitry Osipenko
17.08.2021 10:55, Viresh Kumar пишет: ... >> +int dev_pm_opp_sync(struct device *dev) >> +{ >> +struct opp_table *opp_table; >> +struct dev_pm_opp *opp; >> +int ret = 0; >> + >> +/* Device may not have OPP table */ >> +opp_table = _find_opp_table(dev); >> +if (IS_ERR(opp_tab

Re: [PATCH v8 01/34] opp: Add dev_pm_opp_sync() helper

2021-08-17 Thread Viresh Kumar
On 17-08-21, 04:27, Dmitry Osipenko wrote: > Add dev_pm_opp_sync() helper which syncs OPP table with hardware state > and vice versa. > > Signed-off-by: Dmitry Osipenko > --- > drivers/opp/core.c | 42 +++--- > include/linux/pm_opp.h | 6 ++ > 2 files