From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: David Miller <davem@davemloft.net>
Cc: arnd@arndb.de, linux-arm-kernel@lists.infradead.org,
linux-usb@vger.kernel.org, Ulrich.Weigand@de.ibm.com,
gcc@gcc.gnu.org, linux-kernel@vger.kernel.org,
peter.maydell@linaro.org
Subject: Re: ARM unaligned MMIO access with attribute((packed))
Date: Wed, 2 Feb 2011 21:45:22 +0000 [thread overview]
Message-ID: <20110202214522.GG31043@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20110202.133831.193702414.davem@davemloft.net>
On Wed, Feb 02, 2011 at 01:38:31PM -0800, David Miller wrote:
> From: Russell King - ARM Linux <linux@arm.linux.org.uk>
> Date: Wed, 2 Feb 2011 16:37:02 +0000
>
> > 1. there's no way to tell GCC that the inline assembly is a load
> > instruction and therefore it needs to schedule the following
> > instructions appropriately.
>
> Just add a dummy '"m" (pointer)' asm input argument to the inline asm
> statement. Just make sure "typeof(pointer)" has a size matching the
> size of the load your are performing.
That involves this problematical cast from a packed struct pointer to
an unsigned long pointer, which according to the C standard and GCC
folk is undefined.
> > 2. GCC will needlessly reload pointers from structures and other such
> > behaviour because it can't be told clearly what the inline assembly
> > is doing, so the inline asm needs to have a "memory" clobber.
>
> This behavior is correct, and in fact needed. Writing to chip registers
> can trigger changes to arbitrary main memory locations.
That is really not an argument which stands up to analysis.
When does main memory locations change as a result of a write to a chip
register? The answer is: when DMA is performed - which could be
many microseconds or even milliseconds after you've written the
register, which would be long after you've exited the function doing
the writing.
Not only that, but we have the DMA API to deal with the implications of
that. On ARM, that's a function call, and GCC can't make any assumptions
about memory contents across function calls where it doesn't know what
the function does.
Practice over the last 15 years on ARM has also shown that this is not
necessary.
next prev parent reply other threads:[~2011-02-02 21:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-02 16:00 ARM unaligned MMIO access with attribute((packed)) Arnd Bergmann
2011-02-02 16:37 ` Russell King - ARM Linux
2011-02-02 17:39 ` Arnd Bergmann
2011-02-02 19:14 ` Ian Lance Taylor
2011-02-02 21:38 ` David Miller
2011-02-02 21:45 ` Russell King - ARM Linux [this message]
2011-02-02 21:59 ` David Miller
2011-02-02 23:08 ` Måns Rullgård
2011-02-02 23:23 ` David Miller
2011-02-03 9:26 ` Arnd Bergmann
2011-02-03 15:03 ` Arnd Bergmann
2011-02-02 16:51 ` Richard Guenther
2011-02-02 17:09 ` Russell King - ARM Linux
2011-02-02 17:39 ` Joseph S. Myers
2011-04-26 15:00 ` Rabin Vincent
2011-04-26 18:51 ` Alan Stern
2011-04-27 14:06 ` Rabin Vincent
2011-04-27 16:25 ` Alan Stern
2011-04-27 16:37 ` Arnd Bergmann
2011-04-28 13:35 ` Alan Stern
2011-04-28 14:16 ` Arnd Bergmann
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=20110202214522.GG31043@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=gcc@gcc.gnu.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.maydell@linaro.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).