xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, patches@linaro.org,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 4/7] xen/arm: gic: Use the correct CPU ID
Date: Tue, 10 Sep 2013 17:45:03 +0100	[thread overview]
Message-ID: <522F4C8F.3080806@linaro.org> (raw)
In-Reply-To: <1378828360.10928.35.camel@kazak.uk.xensource.com>

On 09/10/2013 04:52 PM, Ian Campbell wrote:
> On Tue, 2013-09-10 at 16:42 +0100, Julien Grall wrote:
>> On 09/09/2013 02:28 PM, Ian Campbell wrote:
>>> On Fri, 2013-08-30 at 14:30 +0100, Julien Grall wrote:
>>>> The GIC mapping of CPU interfaces does not necessarily match the logical
>>>> CPU numbering.
>>>>
>>>> When Xen wants to send an SGI to specific CPU, it needs to use the GIC CPU ID.
>>>> It can be retrieved from ITARGETSR0, in fact when this field is read, the GIC
>>>> will return a value that corresponds only to the processor reading the register.
>>>> So Xen can use the PPI 0 to initialize the mapping.
>>>>
>>>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
>>>> ---
>>>>  xen/arch/arm/gic.c |   35 ++++++++++++++++++++++++++++-------
>>>>  1 file changed, 28 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
>>>> index cadc258..4f3a8a5 100644
>>>> --- a/xen/arch/arm/gic.c
>>>> +++ b/xen/arch/arm/gic.c
>>>> @@ -57,6 +57,27 @@ static DEFINE_PER_CPU(uint64_t, lr_mask);
>>>>  
>>>>  static unsigned nr_lrs;
>>>>  
>>>> +/* The GIC mapping of CPU interfaces does not necessarily match the
>>>> + * logical CPU numbering. Let's use mapping as returned by the GIC
>>>> + * itself
>>>> + */
>>>> +#define NR_GIC_CPU_IF 8
>>>> +static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly = {0xff};
>>>
>>> Isn't this mapping from logical cpus ids to gic cpus ids? IOW the size
>>> of this array is the wrong way around?
>>
>> This array maps a logical cpu id (the index) to a gic cpus id. The size
>> if correct, because Xen will allocate logical cpu id from 0 to 7.
> 
> Oh right, yes.
> 
> I think NR_CPUS (which should be 8 given the other limitations) is the
> right size for this array.
> 
>>
>>> Is what you want here is a per-cpu variable?
>>
>> Does per-cpu variable allow any cpu to retrieve data of another cpu? I
>> didn't find a such function.
> 
> per_cpu(variable, cpu) will do it.

Is it fast ? I think this solution is slower, because the mapping is
used often used, mainly when an SGI is sent to another cpu.

>>
>>>> +
>>>> +static unsigned int gic_cpu_mask(const cpumask_t *cpumask)
>>>> +{
>>>> +    unsigned int cpu;
>>>> +    unsigned int mask = 0;
>>>> +
>>>> +    for_each_cpu(cpu, cpumask)
>>>> +    {
>>>> +        ASSERT(cpu < NR_GIC_CPU_IF);
>>>> +        mask |= gic_cpu_map[cpu];
>>>
>>> Further to above, can't cpu here be e.g. 0x100 for an a7 on a big.ITTLE
>>> system?
>>
>> 0x100 is the hardware CPU id. Xen will allocate a logical cpu id from 0.
> 
> Right.
> 
> 


-- 
Julien Grall

  reply	other threads:[~2013-09-10 16:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 13:30 [PATCH 0/7] Dissociate logical and gic/hardware CPUD ID Julien Grall
2013-08-30 13:30 ` [PATCH 1/7] xen/arm: Introduce MPIDR_HWID_MASK Julien Grall
2013-09-09 13:09   ` Ian Campbell
2013-09-09 14:06     ` Ian Campbell
2013-08-30 13:30 ` [PATCH 2/7] xen/arm: use cpumask_t to describe cpu mask in gic_route_dt_irq Julien Grall
2013-09-09 13:14   ` Ian Campbell
2013-09-10 15:09     ` Julien Grall
2013-08-30 13:30 ` [PATCH 3/7] xen/arm: Initialize correctly IRQ routing Julien Grall
2013-09-09 13:17   ` Ian Campbell
2013-09-10 15:26     ` Julien Grall
2013-09-10 15:29     ` Julien Grall
2013-09-10 15:36       ` Ian Campbell
2013-08-30 13:30 ` [PATCH 4/7] xen/arm: gic: Use the correct CPU ID Julien Grall
2013-09-09 13:28   ` Ian Campbell
2013-09-10 15:42     ` Julien Grall
2013-09-10 15:52       ` Ian Campbell
2013-09-10 16:45         ` Julien Grall [this message]
2013-09-10 16:48           ` Ian Campbell
2013-08-30 13:30 ` [PATCH 5/7] xen/arm: Fix assert in send_SGI_one Julien Grall
2013-09-09 13:30   ` Ian Campbell
2013-09-10 15:47     ` Julien Grall
2013-08-30 13:30 ` [PATCH 6/7] xen/arm: Dissociate logical and hardware CPU ID Julien Grall
2013-09-09 13:38   ` Ian Campbell
2013-09-10 16:18     ` Julien Grall
2013-08-30 13:30 ` [PATCH 7/7] xen/arm: Use the hardware ID TMP boot correctly secondary cpus Julien Grall
2013-09-09 13:40   ` Ian Campbell
2013-09-10 16:24     ` Julien Grall

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=522F4C8F.3080806@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=patches@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).