linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dave.Martin@arm.com (Dave P Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] ARM: vexpress/TC2: basic PM support
Date: Tue, 18 Jun 2013 18:24:34 +0100	[thread overview]
Message-ID: <20130618172434.GI3289@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.03.1306131817310.18597@syhkavp.arg>

On Thu, Jun 13, 2013 at 06:31:32PM -0400, Nicolas Pitre wrote:
> On Thu, 13 Jun 2013, Olof Johansson wrote:

[...]

> /* Keep per-cpu usage count to cope with unordered up/down requests */
> static int tc2_pm_use_count[TC2_MAX_CPUS_PER_CLUSTER][TC2_CLUSTERS];
> 
> #define tc2_cluster_unused(cluster) \
>         (!tc2_pm_use_count[0][cluster] && \
>          !tc2_pm_use_count[1][cluster] && \
>          !tc2_pm_use_count[2][cluster])
> 
> > > +	if (!tc2_pm_use_count[0][cluster] &&
> > > +	    !tc2_pm_use_count[1][cluster] &&
> > > +	    !tc2_pm_use_count[2][cluster])
> > 
> > I see this construct used three times open-coded like this in the file. Adding
> > a smaller helper with a descriptive name would be a good idea.
> 
> Good observation.  Being too close to this code makes those issues 
> invisible.  Hence the tc2_cluster_unused() above.
> 
> > Same goes for other direct accesses to the array -- maybe a tiny helper to
> > set/get state? It might end up overabstracted that way though.
> 
> I would think so.

True, but it's worth noting that most mcpm backends (certainly any
native backends) will end up duplicating this pattern.  We already
have it for the fast model and for TC2.


In this code, the use counts are doing basically the same thing as
the low-level mcpm coordination, but to coordinate things that can
happen while all affected CPUs' MMUs are on -- this we can use
proper spinlocks and be nice and efficient.  But there are still
parallels between the operations on the use counts array and the
low-level __mcpm_ state machine helpers.

There are some interesting wrinkles here, such as the fact that
tc2_pm_powered_up() chooses a first man to perform some post-MMU
actions using regular spinlocking and the use counts... but this
isn't necessarily the same CPU selected as first man by the
low-level pre-MMU synchronisation.  And that's not a bug, because
we want the winner at each stage to dash across the finish line:
waiting for the runners-up just incurs latency.


Much about this feels like it's solving a common but non-trivial
problem, so there could be an argument for having more framework, or
otherwise documenting it a bit more.

We seem to have the following basic operations:

	lock_for_power_down(cpu, cluster) ->

		cluster and CPU need to be powered on, lock is held for both;
		CPU needs to be powered on, lock is held for it; or
		CPU is already on, so do nothing, lock is not held.

	lock_for_power_up(cpu, cluster) ->

		CPU and cluster need to be powered down (last man), lock is held for both; or
		CPU needs to be powered down, lock is held for it; or
		Someone is already turning the CPU on, so do nothing, lock is not held.

	lock_for_setup(cpu, cluster) ->

		cluster needs to be put into the powered-on state (post-MMU first man), lock is held for it.
		cluster is already in the powrered-on state, so do nothing, lock is not held.

	unlock()

		guess


These may not be great names, but hopefully you get the idea.

They correspond to the operations done in .power_up(), .power_down()
and .powered_up() respectively.

Cheers
---Dave

  reply	other threads:[~2013-06-18 17:24 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07  6:39 [PATCH 0/2] MCPM backend for Virtual Express TC2 Nicolas Pitre
2013-06-07  6:39 ` [PATCH 1/2] ARM: vexpress/TC2: basic PM support Nicolas Pitre
2013-06-07 14:26   ` Lorenzo Pieralisi
2013-06-10  3:53     ` Nicolas Pitre
2013-06-10 17:53       ` Lorenzo Pieralisi
2013-06-10 22:39         ` Nicolas Pitre
2013-06-11 13:41           ` Lorenzo Pieralisi
2013-06-11 15:35             ` Nicolas Pitre
2013-06-10 17:01   ` Sudeep KarkadaNagesha
2013-06-10 20:21     ` Nicolas Pitre
2013-06-13 20:32   ` Olof Johansson
2013-06-13 22:31     ` Nicolas Pitre
2013-06-18 17:24       ` Dave P Martin [this message]
2013-06-18 19:50         ` Nicolas Pitre
2013-06-18 19:56           ` Olof Johansson
2013-06-18 22:06             ` Nicolas Pitre
2013-06-19 10:08           ` Dave P Martin
2013-06-07  6:39 ` [PATCH 2/2] ARM: vexpress/TC2: implement PM suspend method Nicolas Pitre
2013-06-07 10:56   ` Lorenzo Pieralisi
2013-06-10  3:56     ` Nicolas Pitre
2013-06-10 16:03       ` Lorenzo Pieralisi
2013-06-07 15:27 ` [PATCH 0/2] MCPM backend for Virtual Express TC2 Pawel Moll
2013-06-10  3:21   ` Nicolas Pitre
2013-06-10  8:59     ` Pawel Moll
2013-06-11  8:41 ` Jon Medhurst (Tixy)
2013-06-11 18:42   ` Nicolas Pitre

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=20130618172434.GI3289@localhost.localdomain \
    --to=dave.martin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).