From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Tony Lindgren <tony@atomide.com>
Cc: Eduardo Valentin <edubezval@gmail.com>, linux-omap@vger.kernel.org
Subject: Re: FOR COMMENT: void __iomem * and similar casts are Bad News
Date: Wed, 3 Sep 2008 22:04:12 +0100 [thread overview]
Message-ID: <20080903210412.GJ19980@flint.arm.linux.org.uk> (raw)
In-Reply-To: <20080903203720.GV23085@atomide.com>
On Wed, Sep 03, 2008 at 01:37:21PM -0700, Tony Lindgren wrote:
> * Russell King - ARM Linux <linux@arm.linux.org.uk> [080903 12:49]:
> > Yes, that will be virtual. But what does it mean to call:
> >
> > omap_set_dma_dest_params()
> >
> > specifying a virtual address? Can the DMA controller cope with DMAing
> > to virtual addresses? My hunch is that the DMA controller can't cope
> > with that, so giving it a virtual address is a bug.
> >
> > Let me change the question: does omap_set_dma_dest_params()'s 4th
> > argument take a virtual or a physical address? If the former, it's
> > prototype is wrong, and its 4th argument needs to be typed as
> > 'void __iomem *' rather than 'unsigned long'. If the latter, the code
> > above is wrong.
>
> The dma src and dest functions take physical addresses so the prototype
> should be void __iomem *.
Grr. No. Let me repeat the rule:
- virtual addresses are pointer like.
- physical addresses are integer like.
So, if it's a physical address, it should be stored in an integer type
large enough to contain it, and that means something like u32, or
unsigned long.
If it's a virtual MMIO address, then it should be something like
'void __iomem *', or if you want to play roulette with compiler padding,
'struct foo __iomem *'.
Okay, so lets accept that the 4th argument to omap_set_dma_dest_params()
is a physical address. It should be typed as 'unsigned long' (it is)
and it then means that:
diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c
index d084405..d9b1a42 100644
--- a/arch/arm/plat-omap/mcbsp.c
+++ b/arch/arm/plat-omap/mcbsp.c
@@ -652,6 +652,7 @@ int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer,
omap_set_dma_dest_params(mcbsp[id].dma_tx_lch,
src_port,
OMAP_DMA_AMODE_CONSTANT,
+ /* FIXME: this is a virtual address */
mcbsp[id].io_base + OMAP_MCBSP_REG_DXR1,
0, 0);
@@ -713,6 +714,7 @@ int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer,
omap_set_dma_src_params(mcbsp[id].dma_rx_lch,
src_port,
OMAP_DMA_AMODE_CONSTANT,
+ /* FIXME: this is a virtual address */
mcbsp[id].io_base + OMAP_MCBSP_REG_DRR1,
0, 0);
are broken because they're passing a virtual address into a function
requiring a physical address.
Now, to fix this in the right way isn't going to be easy, because
arch/arm/plat-omap/mcbsp.c doesn't know what the physical address of
the mcbsp actually is - it's only passed the virtual address via
platform data (eww, yuck yuck yuck)...
If this was a properly reviewed platform driver, and on *any* *other*
ARM platform, it would take the resources containing the physical
addresses and ioremap them... and this would be a trivial bug fix.
I'll cook a patch up.
next prev parent reply other threads:[~2008-09-03 21:04 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 22:08 FOR COMMENT: void __iomem * and similar casts are Bad News Russell King
2008-08-31 21:47 ` David Brownell
2008-09-02 22:15 ` Tony Lindgren
2008-09-03 7:55 ` Russell King - ARM Linux
2008-09-03 16:40 ` Tony Lindgren
2008-09-03 19:34 ` Russell King - ARM Linux
2008-09-03 19:48 ` Tony Lindgren
2008-09-03 21:09 ` David Brownell
2008-09-03 23:02 ` Russell King - ARM Linux
2008-09-03 19:58 ` Woodruff, Richard
2008-09-03 20:30 ` Russell King - ARM Linux
2008-09-03 21:19 ` Woodruff, Richard
2008-09-03 20:32 ` Tony Lindgren
2008-09-03 21:32 ` Woodruff, Richard
2008-09-03 21:35 ` Tony Lindgren
2008-09-03 21:38 ` Russell King - ARM Linux
2008-09-03 21:46 ` Multi-Boot: Was " Woodruff, Richard
2008-09-03 21:18 ` David Brownell
2008-09-03 21:40 ` Woodruff, Richard
2008-09-03 22:05 ` David Brownell
2008-09-03 22:56 ` Russell King - ARM Linux
2008-09-04 0:28 ` Tony Lindgren
2008-09-04 1:06 ` David Brownell
2008-09-04 7:25 ` Arun KS
2008-09-03 15:07 ` Eduardo Valentin
2008-09-03 18:01 ` Tony Lindgren
2008-09-04 0:16 ` David Brownell
2008-09-03 15:33 ` Eduardo Valentin
2008-09-03 18:48 ` Russell King
2008-09-03 19:33 ` Eduardo Valentin
2008-09-03 19:48 ` Russell King - ARM Linux
2008-09-03 20:04 ` Eduardo Valentin
2008-09-03 20:45 ` Russell King - ARM Linux
2008-09-03 20:50 ` Tony Lindgren
2008-09-03 20:56 ` Tony Lindgren
2008-09-03 21:07 ` Russell King - ARM Linux
2008-09-03 21:13 ` Tony Lindgren
2008-09-03 21:00 ` Koen Kooi
2008-09-03 20:37 ` Tony Lindgren
2008-09-03 21:04 ` Russell King - ARM Linux [this message]
2008-09-03 21:26 ` Eduardo Valentin
2008-09-03 21:48 ` Tony Lindgren
2008-09-03 21:35 ` David Brownell
2008-09-03 23:16 ` Russell King - ARM Linux
2008-09-04 9:46 ` Russell King - ARM Linux
2008-09-04 16:10 ` Tony Lindgren
2008-09-04 16:12 ` Russell King - ARM Linux
2008-09-04 16:29 ` Tony Lindgren
2008-09-04 17:07 ` Russell King - ARM Linux
2008-09-04 17:58 ` Tony Lindgren
2008-09-04 21:01 ` Russell King - ARM Linux
2008-09-04 21:20 ` Tony Lindgren
2008-09-05 1:07 ` Tony Lindgren
2008-09-05 5:17 ` Paul Walmsley
2008-09-05 5:58 ` Paul Walmsley
2008-09-29 5:16 ` Arun KS
2008-09-29 7:44 ` Jarkko Nikula
2008-09-29 9:24 ` Arun KS
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=20080903210412.GJ19980@flint.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=edubezval@gmail.com \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.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