xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Thomas Leonard <talex5@gmail.com>
Cc: David Scott <Dave.Scott@eu.citrix.com>,
	Anil Madhavapeddy <anil@recoil.org>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Samuel Thibault <samuel.thibault@ens-lyon.org>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH ARM v8 2/4] mini-os: arm: interrupt controller
Date: Tue, 28 Oct 2014 15:51:18 +0000	[thread overview]
Message-ID: <544FBB76.7050102@linaro.org> (raw)
In-Reply-To: <CAG4opy-th0P+BBaRJOHeSP0jo=2hS1MqqVM2793q6NdB8jvEKA@mail.gmail.com>

On 10/28/2014 03:43 PM, Thomas Leonard wrote:
> On 28 October 2014 15:25, Julien Grall <julien.grall@linaro.org> wrote:
>> On 10/28/2014 03:15 PM, Thomas Leonard wrote:
>>> On 22 October 2014 14:06, Julien Grall <julien.grall@linaro.org> wrote:
>>>> On 10/22/2014 10:03 AM, Ian Campbell wrote:
>>>>> On Tue, 2014-10-21 at 23:54 +0200, Samuel Thibault wrote:
>>>>>> Ian Campbell, le Tue 21 Oct 2014 12:00:18 +0100, a écrit :
>>>>>>> On Fri, 2014-10-03 at 10:20 +0100, Thomas Leonard wrote:
>>>>>>>> +static inline uint32_t REG_READ32(volatile uint32_t *addr)
>>>>>>>> +{
>>>>>>>> +    uint32_t value;
>>>>>>>> +    __asm__ __volatile__("ldr %0, [%1]":"=&r"(value):"r"(addr));
>>>>>>>> +    rmb();
>>>>>>>
>>>>>>> I'm not 100% convinced that you need this rmb().
>>>>
>>>> Most the GIC code doesn't require read barrier but...
>>>>
>>>>>>>
>>>>>>>> +    return value;
>>>>>>>> +}
>>>>>>>> +
>>>>>>>> +static inline void REG_WRITE32(volatile uint32_t *addr, unsigned int value)
>>>>>>>> +{
>>>>>>>> +    __asm__ __volatile__("str %0, [%1]"::"r"(value), "r"(addr));
>>>>>>>> +    wmb();
>>>>>>>> +}
>>>>
>>>> write barrier may be necessary on some, where we need to wait that all
>>>> write has been done before doing this one (such as enable the GIC ...).
>>>>
>>>> So this function is buggy. It should be:
>>>>
>>>> wmb();
>>>> __asm__ __volatile__(....).
>>>
>>> gic_init does an explicit wmb() before enabling the GIC anyway,
>>> although I'm not really sure why it's needed (these barriers are from
>>> Karim's original code, so I don't know the original reason for them).
>>> Xen will have marked the GIC memory as device memory, so I guess we're
>>> protected from many effects ("The number, order and sizes of the
>>> accesses are maintained.").
>>
>> Device memory doesn't mean the barrier are not necessary... The barriers
>> are there for the whole memory, not only the GIC memory.
>>
>> A common use case is sending an SGI. You need to ensure that every
>> read/write before the SGI will be seen by the other processors.
>> Otherwise they may not see correctly the data.
> 
> Right, but I mean in the context of this code. The only things we're doing are:
> 
> - enabling interrupts (in gic_init)

You need to take care of the barrier/lock for enabling interrupts. Other
processor may be present at that time.

Though IIRC, mini-os for ARM is not yet SMP.

> - reading and acking an interrupt (in gic_handler)

You don't care for this part as it's per CPU.

[..]

> If enabling interrupts is delayed slightly, it shouldn't have any
> effect (even if we get to block_domain, wfi will flush the writes).

Relying on a later flush that is currently existing is not the right
thing to do. You don't know how mini-os will evolve.

You have to check if barriers are needed everywhere.

Regards,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-10-28 15:51 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-03  9:20 [PATCH ARM v8 0/4] mini-os: initial ARM support Thomas Leonard
2014-10-03  9:20 ` [PATCH ARM v8 1/4] mini-os: arm: time Thomas Leonard
2014-10-21 10:50   ` Ian Campbell
2014-10-21 14:07     ` [PATCH incomplete] xen: arm: wallclock support (incomplete, needs work/refactoring) Ian Campbell
2014-10-26  9:51     ` [PATCH ARM v8 1/4] mini-os: arm: time Thomas Leonard
2014-10-27 10:34       ` Ian Campbell
2014-11-13 16:29         ` Thomas Leonard
2014-11-14 10:29           ` Ian Campbell
2014-11-19 20:57             ` Konrad Rzeszutek Wilk
2015-01-08 15:52     ` Ian Campbell
2015-01-08 15:58       ` Thomas Leonard
2015-01-08 16:04         ` Ian Campbell
2014-10-03  9:20 ` [PATCH ARM v8 2/4] mini-os: arm: interrupt controller Thomas Leonard
2014-10-21 11:00   ` Ian Campbell
2014-10-21 14:26     ` Julien Grall
2014-10-21 15:16       ` Ian Campbell
2014-10-21 15:22         ` Julien Grall
2014-10-21 15:35           ` Ian Campbell
2014-10-21 16:03             ` Julien Grall
2014-10-21 18:14               ` Anil Madhavapeddy
2014-10-21 19:18                 ` Ian Campbell
2014-10-21 21:54     ` Samuel Thibault
2014-10-22  9:03       ` Ian Campbell
2014-10-22 13:06         ` Julien Grall
2014-10-22 13:14           ` Samuel Thibault
2014-10-28 15:15           ` Thomas Leonard
2014-10-28 15:25             ` Julien Grall
2014-10-28 15:43               ` Thomas Leonard
2014-10-28 15:51                 ` Julien Grall [this message]
2014-11-14 10:22                   ` Thomas Leonard
2014-11-14 11:33                     ` Julien Grall
2014-11-14 11:42                       ` Ian Campbell
2014-11-14 11:48                         ` Julien Grall
2014-11-14 12:01                           ` Ian Campbell
2014-10-03  9:20 ` [PATCH ARM v8 3/4] mini-os: arm: build system Thomas Leonard
2014-10-21 11:44   ` Ian Campbell
2014-10-21 21:50     ` Samuel Thibault
2014-10-22  9:01       ` Ian Campbell
2014-10-22  9:59         ` Samuel Thibault
2014-10-26  9:46       ` Thomas Leonard
2014-10-26  9:55         ` Samuel Thibault
2014-10-26 10:25           ` Thomas Leonard
2014-11-17 11:42             ` Thomas Leonard
2014-11-17 11:45               ` Ian Campbell
2014-11-17 11:47               ` Andrew Cooper
2014-11-17 11:47               ` Samuel Thibault
2014-10-03  9:20 ` [PATCH ARM v8 4/4] mini-os: arm: show registers, stack and exception vector on fault Thomas Leonard

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=544FBB76.7050102@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Dave.Scott@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=anil@recoil.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=talex5@gmail.com \
    --cc=xen-devel@lists.xenproject.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).