public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Zhaoyang Huang <zhaoyang.huang@linaro.org>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Zhaoyang Huang (黄朝阳)" <zhaoyang.huang@spreadtrum.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	will.deacon@arm.com, linux-kernel@vger.kernel.org,
	"Hanjun Guo" <hanjun.guo@linaro.org>,
	suzuki.poulose@arm.com
Subject: Re: [RFC PATCH v2] Add IPI entry for CPU UP
Date: Fri, 22 Jan 2016 08:07:08 +0000	[thread overview]
Message-ID: <20160122080708.0b7efde9@why.wild-wind.fr.eu.org> (raw)
In-Reply-To: <CAN2waFuJDqPiG4tmn8Q2pKTkEoh8sDTVDefQZdXnr6PFO+bk4w@mail.gmail.com>

On Fri, 22 Jan 2016 10:01:24 +0800
Zhaoyang Huang <zhaoyang.huang@linaro.org> wrote:

> On 21 January 2016 at 18:51, Mark Rutland <mark.rutland@arm.com>
> wrote:
> > On Thu, Jan 21, 2016 at 04:48:57PM +0800, Zhaoyang Huang wrote:
> >> Hi Mark,
> >
> > Hi,
> >
> >> Do you have any suggestion on how to sync the GIC operation from
> >> kernel and psci parallelly? Thanks!
> >
> > I'm not sure what you mean.
> >
> > What problem are you having with synchronising GIC accesses?
> >
> > As far as I can see, the CPU sending the IPI can simply poke the
> > relevant register in the distributor without requiring any
> > synchronisation. The CPU receiving the IPI is the only CPU with
> > access to its CPU interface.
> >
> > Could you describe your problem in more detail?
> >
> > Thanks,
> > Mark.
> >
> Hi Mark,
> Sorry for making confusions. I mean mutex between kernel and trustzone
> when accessing
> GIC registers. It is possible for they two issuing an accessing to the
> same register at the
> same time. How should I handle such kind of race conditions?

The GIC programming interface is designed to allow this kind of access
without locking:

- CPU interface: the CPU cannot be in secure and non-secure at the same
  time, so there is no race for the access. Furthermore, the fact that
  secure interrupts have a higher priority than non-secure ones ensure
  that a secure interrupt will preempt a non-secure one, making the
  whole thing race free.

- Distributor: Writing to the GICD_SGIR register is atomic, and the GIC
  will ensure simultaneous access.

In a nutshell, there is no need to worry about these things, because
the GIC architecture has been designed from the ground up to support
this.

See for example this:
http://git.denx.de/?p=u-boot.git;a=blob_plain;f=arch/arm/cpu/armv7/sunxi/psci_sun7i.S;hb=HEAD

which uses IPIs to implement PSCI on an existing ARMv7 system.

Thanks,

	M.
-- 
Without deviation from the norm, progress is not possible.

      reply	other threads:[~2016-01-22  8:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12  2:05 [RFC PATCH v2] Add IPI entry for CPU UP Zhaoyang Huang
2016-01-12  2:17 ` Zhaoyang Huang
2016-01-12  9:38   ` Lorenzo Pieralisi
2016-01-12  9:42     ` Zhaoyang Huang
2016-01-12 11:51     ` Mark Rutland
2016-01-21  8:48       ` Zhaoyang Huang
2016-01-21 10:51         ` Mark Rutland
2016-01-22  2:01           ` Zhaoyang Huang
2016-01-22  8:07             ` Marc Zyngier [this message]

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=20160122080708.0b7efde9@why.wild-wind.fr.eu.org \
    --to=marc.zyngier@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hanjun.guo@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will.deacon@arm.com \
    --cc=zhaoyang.huang@linaro.org \
    --cc=zhaoyang.huang@spreadtrum.com \
    /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