From: Nicolas Pitre <nico@cam.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: wrong usage of MAX_DMA_ADDRESS in bootmem.h
Date: Tue, 30 Sep 2008 15:35:01 -0400 (EDT) [thread overview]
Message-ID: <alpine.LFD.2.00.0809301513260.3635@xanadu.home> (raw)
In-Reply-To: <20080930184411.GJ15911@flint.arm.linux.org.uk>
I have implemented highmem for ARM. To catch wrong usage of __pa() and
__va() with out of range values, I added a range check when
CONFIG_DEBUG_HIGHMEM is set.
One issue is that bootmem.h uses __pa(MAX_DMA_ADDRESS). However
MAX_DMA_ADDRESS on ARM is defined as 0xffffffff because there is usually
no restriction on the maximum DMA-able address.
RMK suggested that those places should be using ISA_DMA_THRESHOLD
instead -- here's an excert of our conversation on this topic:
> I suspect all those places which are doing __pa(MAX_DMA_ADDRESS) really
> want to be using ISA_DMA_THRESHOLD - that's something to raise on LKML
> if it's causing problems.
>
> > > Given the definition I've just given, if there's no restrictions on
> > > what can be DMA'd from, defining 'MAX_DMA_ADDRESS' to a constant well
> > > in excess of the maximum amount of RAM is quite reasonable. Since most
> > > ARM platforms don't have any restrictions on memory that can be DMA'd,
> > > the existing code is perfectly reasonable and correct.
> >
> > It falls apart when the range check on values passed to __pa() is
> > enabled in a highmem context.
>
> As I say, having it in excess of the real amount of RAM fitted is not a
> problem. Unfortunately, it makes the range check fall apart but I suspect
> that's because of inappropriate use.
So what about this patch?
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 95837bf..7a97ffe 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -96,21 +96,21 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
unsigned long goal);
#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
#define alloc_bootmem(x) \
- __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem(x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
#define alloc_bootmem_nopanic(x) \
- __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
#define alloc_bootmem_low(x) \
__alloc_bootmem_low(x, SMP_CACHE_BYTES, 0)
#define alloc_bootmem_pages(x) \
- __alloc_bootmem(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem(x, PAGE_SIZE, ISA_DMA_THRESHOLD)
#define alloc_bootmem_pages_nopanic(x) \
- __alloc_bootmem_nopanic(x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem_nopanic(x, PAGE_SIZE, ISA_DMA_THRESHOLD)
#define alloc_bootmem_low_pages(x) \
__alloc_bootmem_low(x, PAGE_SIZE, 0)
#define alloc_bootmem_node(pgdat, x) \
- __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, ISA_DMA_THRESHOLD)
#define alloc_bootmem_pages_node(pgdat, x) \
- __alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
+ __alloc_bootmem_node(pgdat, x, PAGE_SIZE, ISA_DMA_THRESHOLD)
#define alloc_bootmem_low_pages_node(pgdat, x) \
__alloc_bootmem_low_node(pgdat, x, PAGE_SIZE, 0)
#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
next parent reply other threads:[~2008-09-30 19:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1222230419-15661-21-git-send-email-nico@cam.org>
[not found] ` <1222230592-15868-1-git-send-email-nico@cam.org>
[not found] ` <20080930162809.GD15911@flint.arm.linux.org.uk>
[not found] ` <alpine.LFD.2.00.0809301409230.3635@xanadu.home>
[not found] ` <20080930184411.GJ15911@flint.arm.linux.org.uk>
2008-09-30 19:35 ` Nicolas Pitre [this message]
2008-09-30 19:56 ` Christoph Lameter
2008-09-30 20:12 ` Russell King - ARM Linux
2008-09-30 21:09 ` Nicolas Pitre
2008-10-01 12:07 ` Christoph Lameter
2008-10-01 14:06 ` Russell King - ARM Linux
2008-10-01 14:50 ` Christoph Lameter
2008-10-01 15:02 ` Russell King - ARM Linux
2008-10-02 16:49 ` Christoph Lameter
2008-10-02 19:06 ` 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=alpine.LFD.2.00.0809301513260.3635@xanadu.home \
--to=nico@cam.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®