linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/11] Consolidate asm/fixmap.h files
@ 2013-11-25 16:13 Mark Salter
  2013-11-25 16:13 ` [PATCH v2 01/11] Add generic fixmap.h Mark Salter
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Mark Salter @ 2013-11-25 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

Many architectures provide an asm/fixmap.h which defines support for
compile-time 'special' virtual mappings which need to be made before
paging_init() has run. This suport is also used for early ioremap
on x86. Much of this support is identical across the architectures.
This patch consolidates all of the common bits into asm-generic/fixmap.h
which is intended to be included from arch/*/include/asm/fixmap.h.

This has been compiled on x86, arm, powerpc, and sh, but tested
on x86 only.

This is version two of the patch series:

   git://github.com/mosalter/linux.git#fixmap-v2

Version 1 is here:

   git://github.com/mosalter/linux.git#fixmap

Changes from v1:

  * Added acks from feedback.
  * Use BUILD_BUG_ON in fix_to_virt()
  * Fixed ARM patch to make FIXMAP_TOP inclusive of fixmap
    range as is the case in the other architectures.

Mark Salter (11):
  Add generic fixmap.h
  x86: use generic fixmap.h
  arm: use generic fixmap.h
  hexagon: use generic fixmap.h
  metag: use generic fixmap.h
  microblaze: use generic fixmap.h
  mips: use generic fixmap.h
  powerpc: use generic fixmap.h
  sh: use generic fixmap.h
  tile: use generic fixmap.h
  um: use generic fixmap.h

 arch/arm/include/asm/fixmap.h        | 29 +++--------
 arch/arm/mm/init.c                   |  2 +-
 arch/hexagon/include/asm/fixmap.h    | 40 +--------------
 arch/metag/include/asm/fixmap.h      | 32 +-----------
 arch/microblaze/include/asm/fixmap.h | 44 +---------------
 arch/mips/include/asm/fixmap.h       | 33 +-----------
 arch/powerpc/include/asm/fixmap.h    | 44 +---------------
 arch/sh/include/asm/fixmap.h         | 39 +--------------
 arch/tile/include/asm/fixmap.h       | 33 +-----------
 arch/um/include/asm/fixmap.h         | 40 +--------------
 arch/x86/include/asm/fixmap.h        | 59 +---------------------
 include/asm-generic/fixmap.h         | 97 ++++++++++++++++++++++++++++++++++++
 12 files changed, 118 insertions(+), 374 deletions(-)
 create mode 100644 include/asm-generic/fixmap.h

-- 
1.8.3.1

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

* [PATCH v2 01/11] Add generic fixmap.h
  2013-11-25 16:13 [PATCH v2 00/11] Consolidate asm/fixmap.h files Mark Salter
@ 2013-11-25 16:13 ` Mark Salter
  2013-11-25 16:13 ` [PATCH v2 03/11] arm: use " Mark Salter
  2013-12-10  8:48 ` [PATCH v2 00/11] Consolidate asm/fixmap.h files Jonas Bonn
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Salter @ 2013-11-25 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

Many architectures provide an asm/fixmap.h which defines support for
compile-time 'special' virtual mappings which need to be made before
paging_init() has run. This support is also used for early ioremap
on x86. Much of this support is identical across the architectures.
This patch consolidates all of the common bits into asm-generic/fixmap.h
which is intended to be included from arch/*/include/asm/fixmap.h.

Signed-off-by: Mark Salter <msalter@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
CC: linux-arch at vger.kernel.org
CC: Russell King <linux@arm.linux.org.uk>
CC: linux-arm-kernel at lists.infradead.org
CC: Richard Kuo <rkuo@codeaurora.org>
CC: linux-hexagon at vger.kernel.org
CC: James Hogan <james.hogan@imgtec.com>
CC: linux-metag at vger.kernel.org
CC: Michal Simek <monstr@monstr.eu>
CC: microblaze-uclinux at itee.uq.edu.au
CC: linux-mips at linux-mips.org
CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org>
CC: linuxppc-dev at lists.ozlabs.org
---
 include/asm-generic/fixmap.h | 97 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
 create mode 100644 include/asm-generic/fixmap.h

diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
new file mode 100644
index 0000000..5a64ca4
--- /dev/null
+++ b/include/asm-generic/fixmap.h
@@ -0,0 +1,97 @@
+/*
+ * fixmap.h: compile-time virtual memory allocation
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1998 Ingo Molnar
+ *
+ * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
+ * x86_32 and x86_64 integration by Gustavo F. Padovan, February 2009
+ * Break out common bits to asm-generic by Mark Salter, November 2013
+ */
+
+#ifndef __ASM_GENERIC_FIXMAP_H
+#define __ASM_GENERIC_FIXMAP_H
+
+#include <linux/bug.h>
+
+#define __fix_to_virt(x)	(FIXADDR_TOP - ((x) << PAGE_SHIFT))
+#define __virt_to_fix(x)	((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
+
+#ifndef __ASSEMBLY__
+/*
+ * 'index to address' translation. If anyone tries to use the idx
+ * directly without translation, we catch the bug with a NULL-deference
+ * kernel oops. Illegal ranges of incoming indices are caught too.
+ */
+static __always_inline unsigned long fix_to_virt(const unsigned int idx)
+{
+	BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
+	return __fix_to_virt(idx);
+}
+
+static inline unsigned long virt_to_fix(const unsigned long vaddr)
+{
+	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
+	return __virt_to_fix(vaddr);
+}
+
+/*
+ * Provide some reasonable defaults for page flags.
+ * Not all architectures use all of these different types and some
+ * architectures use different names.
+ */
+#ifndef FIXMAP_PAGE_NORMAL
+#define FIXMAP_PAGE_NORMAL PAGE_KERNEL
+#endif
+#ifndef FIXMAP_PAGE_NOCACHE
+#define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
+#endif
+#ifndef FIXMAP_PAGE_IO
+#define FIXMAP_PAGE_IO PAGE_KERNEL_IO
+#endif
+#ifndef FIXMAP_PAGE_CLEAR
+#define FIXMAP_PAGE_CLEAR __pgprot(0)
+#endif
+
+#ifndef set_fixmap
+#define set_fixmap(idx, phys)				\
+	__set_fixmap(idx, phys, FIXMAP_PAGE_NORMAL)
+#endif
+
+#ifndef clear_fixmap
+#define clear_fixmap(idx)			\
+	__set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR)
+#endif
+
+/* Return a pointer with offset calculated */
+#define __set_fixmap_offset(idx, phys, flags)		      \
+({							      \
+	unsigned long addr;				      \
+	__set_fixmap(idx, phys, flags);			      \
+	addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1)); \
+	addr;						      \
+})
+
+#define set_fixmap_offset(idx, phys) \
+	__set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL)
+
+/*
+ * Some hardware wants to get fixmapped without caching.
+ */
+#define set_fixmap_nocache(idx, phys) \
+	__set_fixmap(idx, phys, FIXMAP_PAGE_NOCACHE)
+
+#define set_fixmap_offset_nocache(idx, phys) \
+	__set_fixmap_offset(idx, phys, FIXMAP_PAGE_NOCACHE)
+
+/*
+ * Some fixmaps are for IO
+ */
+#define set_fixmap_io(idx, phys) \
+	__set_fixmap(idx, phys, FIXMAP_PAGE_IO)
+
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_GENERIC_FIXMAP_H */
-- 
1.8.3.1

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

* [PATCH v2 03/11] arm: use generic fixmap.h
  2013-11-25 16:13 [PATCH v2 00/11] Consolidate asm/fixmap.h files Mark Salter
  2013-11-25 16:13 ` [PATCH v2 01/11] Add generic fixmap.h Mark Salter
@ 2013-11-25 16:13 ` Mark Salter
  2013-12-11 23:15   ` Mark Salter
  2013-12-10  8:48 ` [PATCH v2 00/11] Consolidate asm/fixmap.h files Jonas Bonn
  2 siblings, 1 reply; 5+ messages in thread
From: Mark Salter @ 2013-11-25 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

ARM is different from other architectures in that fixmap pages are
indexed with a positive offset from FIXADDR_START. Other architectures
index with a negative offset from FIXADDR_TOP. In order to use the
generic fixmap.h definitions, this patch redefines FIXADDR_TOP to be
inclusive of the useable range. That is, FIXADDR_TOP is the virtual
address of the topmost fixed page. The newly defined FIXADDR_END is
the first virtual address past the fixed mappings.

Signed-off-by: Mark Salter <msalter@redhat.com>
CC: Russell King <linux@arm.linux.org.uk>
CC: linux-arm-kernel at lists.infradead.org
---
 arch/arm/include/asm/fixmap.h | 29 ++++++++---------------------
 arch/arm/mm/init.c            |  2 +-
 2 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h
index bbae919..68ea615 100644
--- a/arch/arm/include/asm/fixmap.h
+++ b/arch/arm/include/asm/fixmap.h
@@ -14,28 +14,15 @@
  */
 
 #define FIXADDR_START		0xfff00000UL
-#define FIXADDR_TOP		0xfffe0000UL
-#define FIXADDR_SIZE		(FIXADDR_TOP - FIXADDR_START)
+#define FIXADDR_END		0xfffe0000UL
+#define FIXADDR_TOP		(FIXADDR_END - PAGE_SIZE)
 
-#define FIX_KMAP_BEGIN		0
-#define FIX_KMAP_END		(FIXADDR_SIZE >> PAGE_SHIFT)
+enum fixed_addresses {
+	FIX_KMAP_BEGIN,
+	FIX_KMAP_END = (FIXADDR_TOP - FIXADDR_START) >> PAGE_SHIFT,
+	__end_of_fixed_addresses
+};
 
-#define __fix_to_virt(x)	(FIXADDR_START + ((x) << PAGE_SHIFT))
-#define __virt_to_fix(x)	(((x) - FIXADDR_START) >> PAGE_SHIFT)
-
-extern void __this_fixmap_does_not_exist(void);
-
-static inline unsigned long fix_to_virt(const unsigned int idx)
-{
-	if (idx >= FIX_KMAP_END)
-		__this_fixmap_does_not_exist();
-	return __fix_to_virt(idx);
-}
-
-static inline unsigned int virt_to_fix(const unsigned long vaddr)
-{
-	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
-	return __virt_to_fix(vaddr);
-}
+#include <asm-generic/fixmap.h>
 
 #endif
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ca907f8..fb61c29 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -632,7 +632,7 @@ void __init mem_init(void)
 			MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
 			MLK(ITCM_OFFSET, (unsigned long) itcm_end),
 #endif
-			MLK(FIXADDR_START, FIXADDR_TOP),
+			MLK(FIXADDR_START, FIXADDR_END),
 			MLM(VMALLOC_START, VMALLOC_END),
 			MLM(PAGE_OFFSET, (unsigned long)high_memory),
 #ifdef CONFIG_HIGHMEM
-- 
1.8.3.1

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

* [PATCH v2 00/11] Consolidate asm/fixmap.h files
  2013-11-25 16:13 [PATCH v2 00/11] Consolidate asm/fixmap.h files Mark Salter
  2013-11-25 16:13 ` [PATCH v2 01/11] Add generic fixmap.h Mark Salter
  2013-11-25 16:13 ` [PATCH v2 03/11] arm: use " Mark Salter
@ 2013-12-10  8:48 ` Jonas Bonn
  2 siblings, 0 replies; 5+ messages in thread
From: Jonas Bonn @ 2013-12-10  8:48 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

Is there some reason you've excluded OpenRISC here?  Did you just miss
it, or does the implementation diverage too much to be usable with
your generic version?

Regards,
Jonas

On 25 November 2013 17:13, Mark Salter <msalter@redhat.com> wrote:
> Many architectures provide an asm/fixmap.h which defines support for
> compile-time 'special' virtual mappings which need to be made before
> paging_init() has run. This suport is also used for early ioremap
> on x86. Much of this support is identical across the architectures.
> This patch consolidates all of the common bits into asm-generic/fixmap.h
> which is intended to be included from arch/*/include/asm/fixmap.h.
>
> This has been compiled on x86, arm, powerpc, and sh, but tested
> on x86 only.
>
> This is version two of the patch series:
>
>    git://github.com/mosalter/linux.git#fixmap-v2
>
> Version 1 is here:
>
>    git://github.com/mosalter/linux.git#fixmap
>
> Changes from v1:
>
>   * Added acks from feedback.
>   * Use BUILD_BUG_ON in fix_to_virt()
>   * Fixed ARM patch to make FIXMAP_TOP inclusive of fixmap
>     range as is the case in the other architectures.
>
> Mark Salter (11):
>   Add generic fixmap.h
>   x86: use generic fixmap.h
>   arm: use generic fixmap.h
>   hexagon: use generic fixmap.h
>   metag: use generic fixmap.h
>   microblaze: use generic fixmap.h
>   mips: use generic fixmap.h
>   powerpc: use generic fixmap.h
>   sh: use generic fixmap.h
>   tile: use generic fixmap.h
>   um: use generic fixmap.h
>
>  arch/arm/include/asm/fixmap.h        | 29 +++--------
>  arch/arm/mm/init.c                   |  2 +-
>  arch/hexagon/include/asm/fixmap.h    | 40 +--------------
>  arch/metag/include/asm/fixmap.h      | 32 +-----------
>  arch/microblaze/include/asm/fixmap.h | 44 +---------------
>  arch/mips/include/asm/fixmap.h       | 33 +-----------
>  arch/powerpc/include/asm/fixmap.h    | 44 +---------------
>  arch/sh/include/asm/fixmap.h         | 39 +--------------
>  arch/tile/include/asm/fixmap.h       | 33 +-----------
>  arch/um/include/asm/fixmap.h         | 40 +--------------
>  arch/x86/include/asm/fixmap.h        | 59 +---------------------
>  include/asm-generic/fixmap.h         | 97 ++++++++++++++++++++++++++++++++++++
>  12 files changed, 118 insertions(+), 374 deletions(-)
>  create mode 100644 include/asm-generic/fixmap.h
>
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arch" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Jonas Bonn
Stockholm, Sweden

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

* [PATCH v2 03/11] arm: use generic fixmap.h
  2013-11-25 16:13 ` [PATCH v2 03/11] arm: use " Mark Salter
@ 2013-12-11 23:15   ` Mark Salter
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Salter @ 2013-12-11 23:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2013-11-25 at 11:13 -0500, Mark Salter wrote:
> ARM is different from other architectures in that fixmap pages are
> indexed with a positive offset from FIXADDR_START. Other architectures
> index with a negative offset from FIXADDR_TOP. In order to use the
> generic fixmap.h definitions, this patch redefines FIXADDR_TOP to be
> inclusive of the useable range. That is, FIXADDR_TOP is the virtual
> address of the topmost fixed page. The newly defined FIXADDR_END is
> the first virtual address past the fixed mappings.
> 
> Signed-off-by: Mark Salter <msalter@redhat.com>
> CC: Russell King <linux@arm.linux.org.uk>
> CC: linux-arm-kernel at lists.infradead.org
> ---

Ping. Any concerns about this?

>  arch/arm/include/asm/fixmap.h | 29 ++++++++---------------------
>  arch/arm/mm/init.c            |  2 +-
>  2 files changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/include/asm/fixmap.h b/arch/arm/include/asm/fixmap.h
> index bbae919..68ea615 100644
> --- a/arch/arm/include/asm/fixmap.h
> +++ b/arch/arm/include/asm/fixmap.h
> @@ -14,28 +14,15 @@
>   */
>  
>  #define FIXADDR_START		0xfff00000UL
> -#define FIXADDR_TOP		0xfffe0000UL
> -#define FIXADDR_SIZE		(FIXADDR_TOP - FIXADDR_START)
> +#define FIXADDR_END		0xfffe0000UL
> +#define FIXADDR_TOP		(FIXADDR_END - PAGE_SIZE)
>  
> -#define FIX_KMAP_BEGIN		0
> -#define FIX_KMAP_END		(FIXADDR_SIZE >> PAGE_SHIFT)
> +enum fixed_addresses {
> +	FIX_KMAP_BEGIN,
> +	FIX_KMAP_END = (FIXADDR_TOP - FIXADDR_START) >> PAGE_SHIFT,
> +	__end_of_fixed_addresses
> +};
>  
> -#define __fix_to_virt(x)	(FIXADDR_START + ((x) << PAGE_SHIFT))
> -#define __virt_to_fix(x)	(((x) - FIXADDR_START) >> PAGE_SHIFT)
> -
> -extern void __this_fixmap_does_not_exist(void);
> -
> -static inline unsigned long fix_to_virt(const unsigned int idx)
> -{
> -	if (idx >= FIX_KMAP_END)
> -		__this_fixmap_does_not_exist();
> -	return __fix_to_virt(idx);
> -}
> -
> -static inline unsigned int virt_to_fix(const unsigned long vaddr)
> -{
> -	BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
> -	return __virt_to_fix(vaddr);
> -}
> +#include <asm-generic/fixmap.h>
>  
>  #endif
> diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
> index ca907f8..fb61c29 100644
> --- a/arch/arm/mm/init.c
> +++ b/arch/arm/mm/init.c
> @@ -632,7 +632,7 @@ void __init mem_init(void)
>  			MLK(DTCM_OFFSET, (unsigned long) dtcm_end),
>  			MLK(ITCM_OFFSET, (unsigned long) itcm_end),
>  #endif
> -			MLK(FIXADDR_START, FIXADDR_TOP),
> +			MLK(FIXADDR_START, FIXADDR_END),
>  			MLM(VMALLOC_START, VMALLOC_END),
>  			MLM(PAGE_OFFSET, (unsigned long)high_memory),
>  #ifdef CONFIG_HIGHMEM

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

end of thread, other threads:[~2013-12-11 23:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-25 16:13 [PATCH v2 00/11] Consolidate asm/fixmap.h files Mark Salter
2013-11-25 16:13 ` [PATCH v2 01/11] Add generic fixmap.h Mark Salter
2013-11-25 16:13 ` [PATCH v2 03/11] arm: use " Mark Salter
2013-12-11 23:15   ` Mark Salter
2013-12-10  8:48 ` [PATCH v2 00/11] Consolidate asm/fixmap.h files Jonas Bonn

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