linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* generic page.h problem
@ 2011-03-23 19:12 Mark Salter
  2011-03-23 19:19 ` Mike Frysinger
  2011-03-23 19:53 ` Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Salter @ 2011-03-23 19:12 UTC (permalink / raw)
  To: arnd; +Cc: linux-kernel

I'm working with a new architecture port (nommu) and was wanting to use
the generic page.h but there is a problem. I'm using CONFIG_FLATMEM with
a non-zero CONFIG_KERNEL_RAM_BASE_ADDRESS. The hardware uses this same
address to access RAM from code and for DMA purposes. The generic page.h
has:

#ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
#define PAGE_OFFSET		(CONFIG_KERNEL_RAM_BASE_ADDRESS)
#else
#define PAGE_OFFSET		(0)
#endif

#ifndef __ASSEMBLY__

#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)

The problem I have is that __va(x) and __pa(x) should do nothing on
this architecture. If I use the following, then everything seems to
work as it should.


diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index 75fec18..4dc4a81 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -73,8 +73,8 @@ extern unsigned long memory_end;
 
 #ifndef __ASSEMBLY__
 
-#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __va(x) ((void *)((unsigned long) (x)))
+#define __pa(x) ((unsigned long) (x))
 
 #define virt_to_pfn(kaddr)     (__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_virt(pfn)       __va((pfn) << PAGE_SHIFT)


Am I missing something here? The only other arch using the generic
page.h is blackfin, but it uses a zero PAGE_OFFSET, so my patch
would have no effect there.

--Mark



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: generic page.h problem
  2011-03-23 19:12 generic page.h problem Mark Salter
@ 2011-03-23 19:19 ` Mike Frysinger
  2011-03-23 19:53 ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2011-03-23 19:19 UTC (permalink / raw)
  To: Mark Salter; +Cc: arnd, linux-kernel

On Wed, Mar 23, 2011 at 15:12, Mark Salter wrote:
> I'm working with a new architecture port (nommu) and was wanting to use
> the generic page.h but there is a problem. I'm using CONFIG_FLATMEM with
> a non-zero CONFIG_KERNEL_RAM_BASE_ADDRESS. The hardware uses this same
> address to access RAM from code and for DMA purposes. The generic page.h
> has:
>
> #ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
> #define PAGE_OFFSET             (CONFIG_KERNEL_RAM_BASE_ADDRESS)
> #else
> #define PAGE_OFFSET             (0)
> #endif
>
> #ifndef __ASSEMBLY__
>
> #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
> #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
>
> The problem I have is that __va(x) and __pa(x) should do nothing on
> this architecture. If I use the following, then everything seems to
> work as it should.
>
>
> diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
> index 75fec18..4dc4a81 100644
> --- a/include/asm-generic/page.h
> +++ b/include/asm-generic/page.h
> @@ -73,8 +73,8 @@ extern unsigned long memory_end;
>
>  #ifndef __ASSEMBLY__
>
> -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
> -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
> +#define __va(x) ((void *)((unsigned long) (x)))
> +#define __pa(x) ((unsigned long) (x))
>
>  #define virt_to_pfn(kaddr)     (__pa(kaddr) >> PAGE_SHIFT)
>  #define pfn_to_virt(pfn)       __va((pfn) << PAGE_SHIFT)
>
>
> Am I missing something here? The only other arch using the generic
> page.h is blackfin, but it uses a zero PAGE_OFFSET, so my patch
> would have no effect there.

the only arch that defines CONFIG_KERNEL_RAM_BASE_ADDRESS is mn10300,
and it seems that this generic page.h was designed with it in mind.
fwiw, the va/pa defs for mn10300 also ignore PAGE_OFFSET.
-mike

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: generic page.h problem
  2011-03-23 19:12 generic page.h problem Mark Salter
  2011-03-23 19:19 ` Mike Frysinger
@ 2011-03-23 19:53 ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2011-03-23 19:53 UTC (permalink / raw)
  To: Mark Salter; +Cc: linux-kernel, linux-arch

On Wednesday 23 March 2011 20:12:53 Mark Salter wrote:
> I'm working with a new architecture port (nommu) and was wanting to use
> the generic page.h but there is a problem. I'm using CONFIG_FLATMEM with
> a non-zero CONFIG_KERNEL_RAM_BASE_ADDRESS. The hardware uses this same
> address to access RAM from code and for DMA purposes. The generic page.h
> has:
> 
> #ifdef CONFIG_KERNEL_RAM_BASE_ADDRESS
> #define PAGE_OFFSET		(CONFIG_KERNEL_RAM_BASE_ADDRESS)
> #else
> #define PAGE_OFFSET		(0)
> #endif
> 
> #ifndef __ASSEMBLY__
> 
> #define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
> #define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
> 
> The problem I have is that __va(x) and __pa(x) should do nothing on
> this architecture. If I use the following, then everything seems to
> work as it should.
> 
> 
> diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
> index 75fec18..4dc4a81 100644
> --- a/include/asm-generic/page.h
> +++ b/include/asm-generic/page.h
> @@ -73,8 +73,8 @@ extern unsigned long memory_end;
>  
>  #ifndef __ASSEMBLY__
>  
> -#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
> -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
> +#define __va(x) ((void *)((unsigned long) (x)))
> +#define __pa(x) ((unsigned long) (x))
>  
>  #define virt_to_pfn(kaddr)     (__pa(kaddr) >> PAGE_SHIFT)
>  #define pfn_to_virt(pfn)       __va((pfn) << PAGE_SHIFT)
> 
> 
> Am I missing something here? The only other arch using the generic
> page.h is blackfin, but it uses a zero PAGE_OFFSET, so my patch
> would have no effect there.

I don't think the handling of nonzero PAGE_OFFSET in asm-generic/page.h
was intentional. When Remis worked on the patch to introduce this file,
the idea was to take the common parts from all related architectures
and come up with a way that works on most of them.

Maybe one of the other arch maintainers has an opinion on this. If
not, I don't mind your patch, just add that to your series when submitting
the architecture for review.

	Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-23 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 19:12 generic page.h problem Mark Salter
2011-03-23 19:19 ` Mike Frysinger
2011-03-23 19:53 ` Arnd Bergmann

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).