All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
	Linux PM <linux-pm@vger.kernel.org>, Takashi Iwai <tiwai@suse.de>,
	Viresh Kumar <viresh.kumar@linaro.org>
Subject: Re: [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed
Date: Sat, 11 Apr 2020 12:41:12 +0800	[thread overview]
Message-ID: <491698e05abba0f2f11488ae070a1b3cc6ec1750.camel@intel.com> (raw)
In-Reply-To: <CAJZ5v0hocQ8Y58hzf0qdW0F_E=c7TPBwL2SV3veAYL0x25d4Zg@mail.gmail.com>

On Fri, 2020-04-10 at 16:10 +0200, Rafael J. Wysocki wrote:
> On Fri, Apr 10, 2020 at 10:02 AM Zhang Rui <rui.zhang@intel.com>
> wrote:
> > 
> > On Thu, 2020-04-09 at 15:34 +0200, Daniel Lezcano wrote:
> > > Hi Rui,
> > > 
> > > 
> > > On 08/04/2020 06:19, Zhang Rui wrote:
> > > > ACPI processor cooling device supports 1 cooling state before
> > > > cpufreq
> > > > driver probed, and 4 cooling states after cpufreq driver
> > > > probed.
> > > 
> > > What is this one state ?
> > 
> > One state means its original state and we can not set it to others.
> > 
> > ACPI processor cooling states are combined of p-state cooling
> > states
> > and a couple of optional t-state cooling states.
> > 
> > Say, if we have a processor device supports 7 throttling states, it
> > actually supports 8 cooling states with cpufreq driver unprobed,
> > and 11
> > cooling states with cpufreq driver probed.
> > 
> > > 
> > > > Thus update the statistics table when the cpufeq driver is
> > > > probed/unprobed.
> > > 
> > > To be honest, the series seems to skirt a problem in the acpi
> > > processor.
> > > 
> > > If there is a new policy, then there is a new cooling device. Why
> > > not
> > > unregister the old one and register the new one ?
> > > 
> > 
> > Good point.
> > IMO, the real problem is that do we support dynamic
> > max_cooling_state
> > or not in the thermal framework.
> > Previously, I thought we don't have a hard rule of static
> > max_cooling_state because we always invoke .get_max_state()
> > callback
> > when we need it. But after a second thought, actually we do have
> > this
> > limitation. For example, when binding cooling devices to thermal
> > zones,
> > the upper limit is set based on the return value of
> > .get_max_state() at
> > the binding time, and we never update the upper limit later.
> > So this ACPI processor issue is not just about statistics table
> > update
> > issue, we actually lose some of its cooling states.
> > 
> > Thus, a new max_state means that all the previous setting of the
> > cooling_device, i.e. all the thermal instances of the cooling
> > device,
> > needs to get updated.
> > 
> > And to fix this, it's better to
> > a. unregister and re-register the cooling device as you suggested.
> > or
> > b. introduce an API that updates the cooling device entirely
> > instead of
> > statistics table only.
> > 
> > For either of the above solutions, we'd better to cleanup the code
> > to
> > invoke .get_max_state() during registration/max_state_reset phase,
> > once, and then always use cached value later.
> > And plus, if we want to follow solution a), it's better to remove
> > .get_max_state() callback and use an integer instead so that every
> > driver knows this limitation.
> > I'd vote for solution a) if there is no soc thermal driver that may
> > return dynamic max_states.
> 
> I believe I mentioned one more option, which would be to introduce an
> optional callback into struct thermal_cooling_device_ops to return
> the
> maximum possible return value of .get_max_state(), say
> .get_max_state_limit().  That would be used for the allocation of the
> stats table and the drivers where the .get_max_state() return value
> could not change might set the new callback to NULL.
> 

For a dynamic max_state cooling device, now the problem is not just
about the statistics table.
Take the ACPI processor cooling device for example, we set its internal
limit based on the return value of .get_max_state() during the cooling
device registration, thus if it returns 1, actually we can not use deep
cooling state later at all.

Plus, when a max_state changed, the meaning of each cooling state may
also actually changed. Say, for ACPI processor, cooling state 2 means
60% of max_freq with cpufreq driver, but means ACPI processor T2
throttle state with cpuferq driver unprobed.

That says, if we don't do a full unregistration and registration in
this case, at least we need to keep the device node but re-evaluate
.get_max_state() and update all its thermal instances, as long as the
statistics table change.

thanks,
rui
> Then, upon a change of the .get_max_state() return value, the driver
> providing it would be responsible for rearranging the stats to
> reflect
> the new set of available states.
> 
> Cheers!


  reply	other threads:[~2020-04-11  4:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08  4:19 [RFC PATCH 1/5] thermal: rename thermal_cooling_device_stats_update() Zhang Rui
2020-04-08  4:19 ` [RFC PATCH 2/5] thermal: create statistics table in two steps Zhang Rui
2020-04-08  4:19 ` [RFC PATCH 3/5] thermal: support statistics table resizing at runtime Zhang Rui
2020-04-08  9:45   ` Takashi Iwai
2020-04-09  2:57     ` Zhang Rui
2020-04-08  4:19 ` [RFC PATCH 4/5] thermal: Add a sanity check for invalid state at stats update Zhang Rui
2020-04-08  4:19 ` [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed Zhang Rui
2020-04-09 13:34   ` Daniel Lezcano
2020-04-10  8:02     ` Zhang Rui
2020-04-10 12:10       ` Daniel Lezcano
2020-04-12  6:13         ` Zhang Rui
2020-04-12 10:07           ` Daniel Lezcano
2020-04-13  2:01             ` Zhang Rui
2020-04-13 18:06               ` Daniel Lezcano
2020-04-16  4:46                 ` Zhang Rui
2020-04-16  7:58                   ` Daniel Lezcano
2020-04-17  2:09                     ` Zhang Rui
2020-04-10 14:10       ` Rafael J. Wysocki
2020-04-11  4:41         ` Zhang Rui [this message]
2020-04-13 16:16   ` kbuild test robot
2020-04-14 12:37   ` Dan Carpenter
2020-04-14 12:37     ` Dan Carpenter
2020-04-08  9:47 ` [RFC PATCH 1/5] thermal: rename thermal_cooling_device_stats_update() Takashi Iwai
2020-04-09  2:59   ` Zhang Rui
2020-05-06 12:07 ` Amit Kucheria
2020-04-13  5:07 [RFC PATCH 5/5] ACPI: processor: do update when maximum cooling state changed kbuild test robot

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=491698e05abba0f2f11488ae070a1b3cc6ec1750.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=tiwai@suse.de \
    --cc=viresh.kumar@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
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.