Re: [PATCH 2/6] Introduce CONFIG_ZONE_DMA

Paul Mundt
2006-09-18T23:25:09Z

On Mon, Sep 18, 2006 at 03:58:52PM -0700, Christoph Lameter wrote:
> On Tue, 19 Sep 2006, Paul Mundt wrote:
> > You've missed the other ZONE_DMA references, if you scroll a bit further
> > down that's where we fill in ZONE_DMA, this is simply the default zone
> > layout that we rely on for nommu.
>
> Are you sure that sh does not need ZONE_DMA? There is code in there
> to check for the DMA boundary. The following patch disables that
> code if CONFIG_ZONE_DMA is not set.
>
Yes, MAX_DMA_ADDRESS (in include/asm-sh/dma.h) is from when we needed it for
alloc_bootmem(), we have no interest in it, but we can't kill off the
definition either since some drivers seem to rely on it.. It was also left
around in case some CPU variants with an arbitrary limitation in their
respective DMACs popped up.

All lowmem fits < MAX_DMA_ADDRESS and so gets stuffed in ZONE_DMA, as
per:

if (low < max_dma) {
zones_size[ZONE_DMA] = low - start_pfn;
zones_size[ZONE_NORMAL] = 0;

So we may as well just do away with it entirely, via something like this:

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 8ea27ca..40494f9 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -156,7 +156,6 @@ void __init paging_init(void)
* Setup some defaults for the zone sizes.. these should be safe
* regardless of distcontiguous memory or MMU settings.
*/
- zones_size[ZONE_DMA] = 0 >> PAGE_SHIFT;
zones_size[ZONE_NORMAL] = __MEMORY_SIZE >> PAGE_SHIFT;
#ifdef CONFIG_HIGHMEM
zones_size[ZONE_HIGHMEM] = 0 >> PAGE_SHIFT;
@@ -168,7 +167,7 @@ #ifdef CONFIG_MMU
* the zone sizes accordingly, in addition to turning it on.
*/
{
- unsigned long max_dma, low, start_pfn;
+ unsigned long low, start_pfn;
pgd_t *pg_dir;
int i;

@@ -183,16 +182,10 @@ #ifdef CONFIG_MMU

/* Fixup the zone sizes */
start_pfn = START_PFN;
- max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
low = MAX_LOW_PFN;

- if (low < max_dma) {
- zones_size[ZONE_DMA] = low - start_pfn;
- zones_size[ZONE_NORMAL] = 0;
- } else {
- zones_size[ZONE_DMA] = max_dma - start_pfn;
- zones_size[ZONE_NORMAL] = low - max_dma;
- }
+ /* No DMA limitation, shove all of lowmem in ZONE_NORMAL. */
+ zones_size[ZONE_NORMAL] = low - start_pfn;
}

#elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4)