From: Saravana Kannan <skannan@codeaurora.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Russell King - ARM Linux <linux@arm.linux.org.uk>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
linux-arm-msm@vger.kernel.org
Subject: Re: CONFIG_ARM_DMA_MEM_BUFFERABLE and readl/writel weirdness
Date: Wed, 02 Mar 2011 23:57:10 -0800 [thread overview]
Message-ID: <4D6F49D6.3080605@codeaurora.org> (raw)
In-Reply-To: <201103020923.36796.arnd@arndb.de>
On 03/02/2011 12:23 AM, Arnd Bergmann wrote:
> On Wednesday 02 March 2011 02:23:15 Saravana Kannan wrote:
>> There are so many other drivers that don't use or care about DMA and
>> might still want to ensure some ordering constraints between their
>> readl(s)/writel(s). They can't depend on readl/writel taking care of it
>> for them since their code could be used in a kernel configuration that
>> doesn't enable this config.
>
> What exactly are the ordering constraints, do you need the full
> dmb() for readl() and dsb() for writel(), or just a compiler barrier?
I wasn't referring to a compiler barrier. I'm referring to one of the
real barrier instructions.
> I think we need the barrier() even for the relaxed variant, but
> that is fairly lightweight. What would be a reason to have more?
Please see my response to Russell in other other email. I think it
should answer your question by clarifying my point.
>> Firstly, I don't know how many people noticed this and realize they
>> can't depend on readl/writel to take care of the mb()s for them. Seems
>> like an unnecessary encouragement to make mistakes when it didn't need
>> to be so.
>>
>> Secondly, even if they realize they have to take care of it, they will
>> have to continue using mb()s in to force ordering between their
>> reads/writes. So, are we depending on the compiler to optimize these
>> extra mb() out in the case where the config is enabled? I'm not sure it
>> will be able to optimize out the extra mb()s in all cases.
>
> The compiler certainly won't merge multiple inline assembly statements,
> but multiple barrier() statements don't make it worse than just one.
> barrier() just forces accessing variables from memory that could otherwise
> be kept in registers.
Yes, I was aware of how compiler barriers work and how multiple
consecutive compiler barriers are the same as one compiler barrier. The
email was about the real barrier instructions.
> The other problems we still need to fix are the complete absence of
> barriers in inb()/outb() style accessors, which are meant to be stricter
> than readl()/writel(), and the fact that we rely on undefined behavior
> in gcc regarding the atomicity of multi-byte accesses, as we recently
> found out when a new gcc turned a readl into byte accesses.
I haven't gotten that far :-) I really appreciate response!
Thanks,
Saravana
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
WARNING: multiple messages have this Message-ID (diff)
From: skannan@codeaurora.org (Saravana Kannan)
To: linux-arm-kernel@lists.infradead.org
Subject: CONFIG_ARM_DMA_MEM_BUFFERABLE and readl/writel weirdness
Date: Wed, 02 Mar 2011 23:57:10 -0800 [thread overview]
Message-ID: <4D6F49D6.3080605@codeaurora.org> (raw)
In-Reply-To: <201103020923.36796.arnd@arndb.de>
On 03/02/2011 12:23 AM, Arnd Bergmann wrote:
> On Wednesday 02 March 2011 02:23:15 Saravana Kannan wrote:
>> There are so many other drivers that don't use or care about DMA and
>> might still want to ensure some ordering constraints between their
>> readl(s)/writel(s). They can't depend on readl/writel taking care of it
>> for them since their code could be used in a kernel configuration that
>> doesn't enable this config.
>
> What exactly are the ordering constraints, do you need the full
> dmb() for readl() and dsb() for writel(), or just a compiler barrier?
I wasn't referring to a compiler barrier. I'm referring to one of the
real barrier instructions.
> I think we need the barrier() even for the relaxed variant, but
> that is fairly lightweight. What would be a reason to have more?
Please see my response to Russell in other other email. I think it
should answer your question by clarifying my point.
>> Firstly, I don't know how many people noticed this and realize they
>> can't depend on readl/writel to take care of the mb()s for them. Seems
>> like an unnecessary encouragement to make mistakes when it didn't need
>> to be so.
>>
>> Secondly, even if they realize they have to take care of it, they will
>> have to continue using mb()s in to force ordering between their
>> reads/writes. So, are we depending on the compiler to optimize these
>> extra mb() out in the case where the config is enabled? I'm not sure it
>> will be able to optimize out the extra mb()s in all cases.
>
> The compiler certainly won't merge multiple inline assembly statements,
> but multiple barrier() statements don't make it worse than just one.
> barrier() just forces accessing variables from memory that could otherwise
> be kept in registers.
Yes, I was aware of how compiler barriers work and how multiple
consecutive compiler barriers are the same as one compiler barrier. The
email was about the real barrier instructions.
> The other problems we still need to fix are the complete absence of
> barriers in inb()/outb() style accessors, which are meant to be stricter
> than readl()/writel(), and the fact that we rely on undefined behavior
> in gcc regarding the atomicity of multi-byte accesses, as we recently
> found out when a new gcc turned a readl into byte accesses.
I haven't gotten that far :-) I really appreciate response!
Thanks,
Saravana
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
next prev parent reply other threads:[~2011-03-03 7:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-02 1:23 CONFIG_ARM_DMA_MEM_BUFFERABLE and readl/writel weirdness Saravana Kannan
2011-03-02 1:23 ` Saravana Kannan
2011-03-02 8:23 ` Arnd Bergmann
2011-03-02 8:23 ` Arnd Bergmann
2011-03-03 7:57 ` Saravana Kannan [this message]
2011-03-03 7:57 ` Saravana Kannan
2011-03-02 8:39 ` Russell King - ARM Linux
2011-03-02 8:39 ` Russell King - ARM Linux
2011-03-03 7:49 ` Saravana Kannan
2011-03-03 7:49 ` Saravana Kannan
2011-03-03 10:11 ` Catalin Marinas
2011-03-03 10:11 ` Catalin Marinas
2011-03-09 4:37 ` Saravana Kannan
2011-03-09 4:37 ` Saravana Kannan
2011-03-03 10:24 ` Russell King - ARM Linux
2011-03-03 10:24 ` Russell King - ARM Linux
2011-03-09 4:58 ` Saravana Kannan
2011-03-09 4:58 ` Saravana Kannan
2011-03-09 8:05 ` Russell King - ARM Linux
2011-03-09 8:05 ` Russell King - ARM Linux
2011-03-09 9:32 ` Saravana Kannan
2011-03-09 9:32 ` Saravana Kannan
2011-03-09 9:38 ` Russell King - ARM Linux
2011-03-09 9:38 ` Russell King - ARM Linux
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=4D6F49D6.3080605@codeaurora.org \
--to=skannan@codeaurora.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
/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.