From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 5/6] ARM, mm: change meaning of max_low_pfn to maximum pfn for nobootmem
Date: Mon, 1 Jul 2013 18:09:41 +0100 [thread overview]
Message-ID: <20130701170941.GC24642@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <51D18ED5.50103@ti.com>
On Mon, Jul 01, 2013 at 10:14:45AM -0400, Santosh Shilimkar wrote:
> I have been also carrying similar patch as yours in an attempt
> to make LPAE kernel work on ARM. Your patch carries better
> description, so will your version and include in my series
> which I plan to post on the list after some more testing.
> Will copy you. The changes are very similar to your series.
And will you try to investigate and/or address my concerns with this
change?
Consider this code in the block layer:
static int __init blk_settings_init(void)
{
blk_max_low_pfn = max_low_pfn - 1;
blk_max_pfn = max_pfn - 1;
return 0;
}
void blk_queue_bounce_limit(struct request_queue *q, u64 dma_mask)
{
unsigned long b_pfn = dma_mask >> PAGE_SHIFT;
...
if (b_pfn < blk_max_low_pfn)
dma = 1;
q->limits.bounce_pfn = b_pfn;
if (dma) {
init_emergency_isa_pool();
q->bounce_gfp = GFP_NOIO | GFP_DMA;
q->limits.bounce_pfn = b_pfn;
}
}
and this in SCSI:
u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
{
struct device *host_dev;
u64 bounce_limit = 0xffffffff;
...
host_dev = scsi_get_device(shost);
if (host_dev && host_dev->dma_mask)
bounce_limit = *host_dev->dma_mask;
return bounce_limit;
}
struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
request_fn_proc *request_fn)
{
...
blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
Now, what happens when you have a device which can only address the first
64MB of system memory, which is at 3GB(physical), but you have 1GB of
system memory available both before changing max_low_pfn, and after
changing max_low_pfn.
Bear in mind that you will find that virtually all places in the kernel
set the device DMA mask to be "DMA_BIT_MASK(number_of_bits_driven)" and
not offset by the base of physical memory. In the above case, consider
what happens with a 24 bit DMA mask.
So... if we make this change, I would much prefer to also see a number
of other patches preceding this one:
(a) blk_queue_bounce_limit()'s parameter renamed from "dma_mask" to
"max_addr" or indeed just taking b_pfn directly.
(b) a helper: dma_max_pfn(dev) which converts a DMA bitmask of bits
to a b_pfn number which is just "dev->dma_mask >> PAGE_SHIFT" in the
generic case, but ARM can override this later.
(c) a patch changing max_low_pfn/max_pfn to include the physical offset
of memory, and providing an ARM version of this which adds in the
appropriate offset.
Here's an example dma_max_pfn() helper for the generic case:
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 48ef6f5..a083724 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -153,6 +153,13 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask)
return -EIO;
}
+#ifndef dma_max_pfn
+static inline unsigned long dma_max_pfn(struct device *dev)
+{
+ return dev->dma_mask ? (*dev->dma_mask >> PAGE_SHIFT) : 0;
+}
+#endif
+
static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
Arches can then override this with:
static inline unsigned long dma_max_pfn(struct device *dev)
{
...
}
#define dma_max_pfn dma_max_pfn
next prev parent reply other threads:[~2013-07-01 17:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 4:11 [RFC PATCH 0/6] ARM: use NO_BOOTMEM on default configuration Joonsoo Kim
2013-03-25 4:11 ` [RFC PATCH 1/6] ARM, TCM: initialize TCM in paging_init(), instead of setup_arch() Joonsoo Kim
2013-03-25 21:18 ` Linus Walleij
2013-03-25 4:11 ` [RFC PATCH 2/6] ARM, crashkernel: use ___alloc_bootmem_node_nopanic() for reserving memory Joonsoo Kim
2013-03-25 4:11 ` [RFC PATCH 3/6] ARM, crashkernel: correct total_mem size in reserve_crashkernel() Joonsoo Kim
2013-03-25 4:11 ` [RFC PATCH 4/6] ARM, mm: don't do arm_bootmem_init() if CONFIG_NO_BOOTMEM Joonsoo Kim
2013-03-25 4:11 ` [RFC PATCH 5/6] ARM, mm: change meaning of max_low_pfn to maximum pfn for nobootmem Joonsoo Kim
2013-03-25 9:48 ` Russell King - ARM Linux
2013-04-01 8:28 ` Joonsoo Kim
2013-07-01 14:14 ` Santosh Shilimkar
2013-07-01 17:09 ` Russell King - ARM Linux [this message]
2013-07-02 17:38 ` Santosh Shilimkar
2013-07-02 1:28 ` Joonsoo Kim
2013-03-25 4:11 ` [RFC PATCH 6/6] ARM, mm: enable NO_BOOTMEM for default ARM build Joonsoo Kim
2013-04-22 8:22 ` [RFC PATCH 0/6] ARM: use NO_BOOTMEM on default configuration Joonsoo Kim
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=20130701170941.GC24642@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=linux-arm-kernel@lists.infradead.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).